[chbot] Chchrobotics Digest, Vol 173, Issue 8

Bevin Brett bevin_brett at hotmail.com
Tue Feb 8 18:19:24 GMT 2022


How are you testing that the first DMA is complete before you start overwriting the buffer with the next payload?

/Bevin
________________________________
From: Chchrobotics <chchrobotics-bounces at lists.ourshack.com> on behalf of chchrobotics-request at lists.ourshack.com <chchrobotics-request at lists.ourshack.com>
Sent: Wednesday, February 9, 2022 1:00 AM
To: chchrobotics at lists.ourshack.com <chchrobotics at lists.ourshack.com>
Subject: Chchrobotics Digest, Vol 173, Issue 8

Send Chchrobotics mailing list submissions to
        chchrobotics at lists.ourshack.com

To subscribe or unsubscribe via the World Wide Web, visit
        https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.ourshack.com%2Fmailman%2Flistinfo%2Fchchrobotics&data=04%7C01%7C%7Cf0d377c61d544f1955c308d9eafa9419%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637799184258756794%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=ucDBPEwjSuVA6oX6IUCL6c3G%2FO8W3tq7PqGBVLM3QcI%3D&reserved=0
or, via email, send a message with subject or body 'help' to
        chchrobotics-request at lists.ourshack.com

You can reach the person managing the list at
        chchrobotics-owner at lists.ourshack.com

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Chchrobotics digest..."


Today's Topics:

   1. Re: Volatile struct puzzle (Robin Gilks)


----------------------------------------------------------------------

Message: 1
Date: Tue, 8 Feb 2022 13:48:38 +1300
From: Robin Gilks <gb7ipd at gmail.com>
To: Christchurch Robotics <chchrobotics at lists.ourshack.com>
Subject: Re: [chbot] Volatile struct puzzle
Message-ID:
        <CAPfE9Ugb37NE-6DqjbL8b0U-na52HO4WMHYBtXNaRidwMUW04g at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I think I understand what SHOULD work, but it doesn't!!

JPEG encode occurs in 3 (4) stages

   1. prepare first block bitmap data by converting to YCbCr. Do a
   SCB_CleanDCache_by_Addr() cache flush to make sure it's all in RAM and not
   cache and accessible to DMA
   2. after processing, flush the cache with SCB_InvalidateDCache_by_Addr()
   to ensure the data read not stale before writing to filesystem
   3. prepare the next YCbCrblock and like (1) flush the cache to make sure
   its all accessible to DMA
   4. repeat 2-3 until all bitmap data done

Now I'm really stuck (other than random rearrangements of the code)


On Tue, Feb 8, 2022 at 1:38 PM Robin Gilks <gb7ipd at gmail.com> wrote:

> I think I understand what SHOULD work, but it doesn't!!
>
> JPEG encode occurs in 3 (4) stages
>
>    1. prepare first block bitmap data by converting to YCbCr. Do a
>    SCB_CleanDCache_by_Addr() cache flush to make sure it's all in RAM and not
>    cache and accessible to DMA
>    2. after processing, flush the cache with
>    SCB_InvalidateDCache_by_Addr() to ensure the data read not stale before
>    writing to filesystem
>    3. prepare the next YCbCrblock and like (1) flush the cache to make
>    sure its all accessible to DMA
>    4. repeat 2-3 until all bitmap data done
>
> Now I'm really stuck (other than random rearrangements of the code)
>
>
> On Mon, Feb 7, 2022 at 3:01 PM Charles Manning <cdhmanning at gmail.com>
> wrote:
>
>> Hi Robin
>>
>> The packing of the structure should not be a factor unless you are
>> fiddling with the packed attribute.
>>
>> When we're talking about caching then there are many things that enter
>> the picture.
>>
>> You say that the buffer itself (which I expect is the target of the DMA
>> rather than anything else) has the correct caching attributes. What are
>> those? From a brief glimpse at the Cortex M7 manuals, you should be
>> ensuring this has the shared  attribute. If this is set correctly then the
>> caching should not matter. What have you done to check the caching is
>> correct?
>> Do not assume that the caching is correct from compiler attributes. Those
>> might not match the settings in the MMU.
>>
>> What you are observing is that in one case the cache appears to be
>> fetched correctly and in the other not.
>> This can be caused by execution of code far away from this point due to
>> how the cache works.
>>
>> A compiler change can reorder instructions and data accesses(especially
>> at -O3). THis can completely change the CPU's interaction with the cache.
>> Throw in an out of order CPU like the M7 and a lot can change.
>>
>> A cache has multiple cache lines and the address being accessed can only
>> map to a few of these cache lines (termed a set). If other code elsewhere
>> needs something in the cache that maps to the same set, then this could be
>> forcing a new cache read - causing the data to be healthy. If, however, the
>> cache is not being refreshed, then the old cached value might be used
>> forever.
>>
>> Assuming the DMA controller is only modifying the buffer, I would try
>> adding the following just before accessing the buffer:
>>
>> /* Force fresh data into the cache */
>> uint32_t jpeg_base = ((uint32_t) JPEG_Data_Buffer) & (~0x1f); /* Calc
>> base 32-byte boundary */
>> uint32_t n_bytes =  ((uint32_t) JPEG_Data_Buffer) - jpeg_base +
>> sizeof(JPEG_Data_Buffer);
>> SCB_InvalidateDCache_by_Addr(jpeg_base, n_bytes);
>> ... now access stuff in the cache.
>>
>>
>>
>>
>>
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.ourshack.com%2Fpipermail%2Fchchrobotics%2Fattachments%2F20220208%2F56f22931%2Fattachment-0001.html&data=04%7C01%7C%7Cf0d377c61d544f1955c308d9eafa9419%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637799184258756794%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=fQoaCaWAqV%2FR3u5J%2BqbH983W2Gy9nZLT14NByt4TFkI%3D&reserved=0>

------------------------------

Subject: Digest Footer

_______________________________________________
Chchrobotics mailing list
Chchrobotics at lists.ourshack.com
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.ourshack.com%2Fmailman%2Flistinfo%2Fchchrobotics&data=04%7C01%7C%7Cf0d377c61d544f1955c308d9eafa9419%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637799184258756794%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=ucDBPEwjSuVA6oX6IUCL6c3G%2FO8W3tq7PqGBVLM3QcI%3D&reserved=0
Mail Archives: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.ourshack.com%2Fpipermail%2Fchchrobotics%2F&data=04%7C01%7C%7Cf0d377c61d544f1955c308d9eafa9419%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637799184258756794%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=NaSBHLiS7moFcdRj%2ByQG6fv8ue2SjCXS2rH1AlZQQl4%3D&reserved=0
Meetings usually 3rd Monday each month. See https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fkiwibots.org%2F&data=04%7C01%7C%7Cf0d377c61d544f1955c308d9eafa9419%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637799184258756794%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=MRPqgOabF559HMKJ8qaSZS278Ye8Fn%2BP2DNa%2BChgHFU%3D&reserved=0 for venue, directions and dates.
Please edit your Subject line to reflect new subjects.

------------------------------

End of Chchrobotics Digest, Vol 173, Issue 8
********************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20220208/ccbf2a81/attachment-0001.html>


More information about the Chchrobotics mailing list