There is a system with ADI BlackFin DSP which boots up from SPI flash. The flash contains the standard ADI boot stream. I would like to insert hw/sw version number, build number, release date and some other information into the flash. This information should be accessible to a program running on Blackfin. Also, the flash programming tools should be able to read this information from the flash hex file. Is there a way to configure the VDSP toolset so this data would be inserted automatically from a C source to a predefined location in the flash? Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Insert version information into a boot stream
Started by ●August 19, 2011
Reply by ●August 19, 20112011-08-19
Vladimir Vassilevsky rote:>There is a system with ADI BlackFin DSP which boots up from SPI flash. >The flash contains the standard ADI boot stream. > >I would like to insert hw/sw version number, build number, release date >and some other information into the flash. This information should be >accessible to a program running on Blackfin. Also, the flash programming >tools should be able to read this information from the flash hex file. > >Is there a way to configure the VDSP toolset so this data would be >inserted automatically from a C source to a predefined location in the >flash?I just went through the same exercise with an ARM STM32 based project. Back to the BlackFin. I have not used them, but I used SHARC devices and expect a similar approach will work. Locate the version information at a fixed RAM address. In the Linker Description File define a segment for the version data along the lines of: MEMORY { .... seg_version_data { TYPE(PM RAM) START(some address) END(some other address) WIDTH(32) } .... } PROCESSOR P0 { KEEP(..., seg_version_data, ... ) OUTPUT( $COMMAND_LINE_OUTPUT_FILE ) SECTIONS { .... seg_version_data { INPUT_SECTIONS( $OBJECTS(seg_version_data)) } > seg_version_data .... } } Then in your code: #pragma section seg_version_data const struct version { /* whatever is needed */ }; I placed the above data in a separate C source file. The structure contains manually edited version information, as well as a time stamp updated at each build, etc. Since (in my case) the external flash is copied as-is to the internal ram, placing the version block at a fixed RAM address will also place it at a fixed location in the flash boot image. As I said, I would expect this to work also with a BlackFin, but never tried it. It would fail if, for example, the boot image is compressed or encrypted. Another approach is to write the version information at the very end of the flash, (with a gap between it an the end of the normal code) and have the BlackFin read it after it is up and running. -- Roberto Waltman [ Please reply to the group. Return address is invalid ]
Reply by ●August 19, 20112011-08-19
Roberto Waltman wrote:> Vladimir Vassilevsky rote: > >>There is a system with ADI BlackFin DSP which boots up from SPI flash. >>The flash contains the standard ADI boot stream. >> >>I would like to insert hw/sw version number, build number, release date >>and some other information into the flash. This information should be >>accessible to a program running on Blackfin. Also, the flash programming >>tools should be able to read this information from the flash hex file. >> >>Is there a way to configure the VDSP toolset so this data would be >>inserted automatically from a C source to a predefined location in the >>flash? > > I just went through the same exercise with an ARM STM32 based project. > Back to the BlackFin. I have not used them, but I used SHARC devices > and expect a similar approach will work. > > Locate the version information at a fixed RAM address. > Since (in my case) the external flash is copied as-is to the internal > ram, placing the version block at a fixed RAM address will also place > it at a fixed location in the flash boot image.Unfortunately, this won't work for BlackFin as the flash boot stream is not a contiguous image of RAM, but a sequence of separate blocks.> Another approach is to write the version information at the very end > of the flash, (with a gap between it an the end of the normal code) > and have the BlackFin read it after it is up and running.This is what we have to do now. This requires a special file in the project just to store and pass the version information, and the separate software tools to manipulate this file and the flash hex image. It does the job albeit not very elegant. Besides, it is tied to the particular flash size. I wonder if there is a good solution to the problem which seems to be very typical. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Reply by ●August 19, 20112011-08-19
Vladimir Vassilevsky wrote:>Unfortunately, this won't work for BlackFin as the flash boot stream is >not a contiguous image of RAM, but a sequence of separate blocks.Could you identify/use one particular block? -- Roberto Waltman [ Please reply to the group. Return address is invalid ]
Reply by ●August 19, 20112011-08-19
Hi Vladimir, On 8/19/2011 8:14 AM, Vladimir Vassilevsky wrote:> > There is a system with ADI BlackFin DSP which boots up from SPI flash. > The flash contains the standard ADI boot stream. > > I would like to insert hw/sw version number, build number, release date > and some other information into the flash. This information should be > accessible to a program running on Blackfin. Also, the flash programming > tools should be able to read this information from the flash hex file. > > Is there a way to configure the VDSP toolset so this data would be > inserted automatically from a C source to a predefined location in the > flash?Instead of requiring a "predefined location" (admittedly, easier to *find*), could you wrap the information with a unique signature such that anything else is unlikely to be (erroneously) recognized as having that signature IN THAT REGION OF MEMORY? E.g., add to the flash image: "Copyright 08192011 Vladimir Vassilevsky, Build 12.3.4, v9A03" (assuming this *context* is unlikely to randomly appear elsewhere in your code image :> )
Reply by ●August 19, 20112011-08-19
Another way, (which I don't like, but it works.) You can enbedd the version info in the flash image surrounded by "markers" that will allow you to search and locate it anywhere. #pragma pack() struct version { char before[35]; int v_major; int v_minor; char date[11]; int checksum; // to reduce the likelihood of false possitives char after[35]; }; struct version this_version = { "find version after this ##########", 0, 0, /* to be updated after build */ "--/--/----", 0, "######### find version before this" }; Of curse, if the boot image includes any checksums to detect corrupted files they will need to be updated after modifying the structure above. -- Roberto Waltman [ Please reply to the group. Return address is invalid ]
Reply by ●August 19, 20112011-08-19
Don Y wrote:>Instead of requiring a "predefined location" (admittedly, easier to >*find*), could you wrap the information with a unique signature >...Are you feeling slightly telepathic? ;) -- Roberto Waltman [ Please reply to the group. Return address is invalid ]
Reply by ●August 19, 20112011-08-19
On 8/19/2011 10:49 AM, Don Y wrote:> Hi Vladimir, > > On 8/19/2011 8:14 AM, Vladimir Vassilevsky wrote: >> >> There is a system with ADI BlackFin DSP which boots up from SPI flash. >> The flash contains the standard ADI boot stream. >> >> I would like to insert hw/sw version number, build number, release date >> and some other information into the flash. This information should be >> accessible to a program running on Blackfin. Also, the flash programming >> tools should be able to read this information from the flash hex file. >> >> Is there a way to configure the VDSP toolset so this data would be >> inserted automatically from a C source to a predefined location in the >> flash? > > Instead of requiring a "predefined location" (admittedly, easier to > *find*), could you wrap the information with a unique signature > such that anything else is unlikely to be (erroneously) recognized > as having that signature IN THAT REGION OF MEMORY? > > E.g., add to the flash image: > > "Copyright 08192011 Vladimir Vassilevsky, Build 12.3.4, v9A03" > > (assuming this *context* is unlikely to randomly appear elsewhere > in your code image :> )Surprisingly, on the Blackfin, that actually disassembles to code that erases the entire flash and then sets the chip on fire. -- Rob Gaddi, Highland Technology Email address is currently out of order
Reply by ●August 19, 20112011-08-19
Roberto Waltman wrote:>Of curse, if ...Pardon me, Freudian slip... -- Roberto Waltman [ Please reply to the group. Return address is invalid ]
Reply by ●August 19, 20112011-08-19
Hi Roberto, On 8/19/2011 10:54 AM, Roberto Waltman wrote:>> Instead of requiring a "predefined location" (admittedly, easier to >> *find*), could you wrap the information with a unique signature >> ... > > Are you feeling slightly telepathic? ;)No, you can use some of the enhanced instructions added to the newer models: OUIJA "Copyright" ;locate "Copyright" in image CHANNEL "Vladimir Vassilevsky" ;(actually only works posthumously)