Insert version information into a boot stream

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

formatting link

Reply to
Vladimir Vassilevsky
Loading thread data ...

Vladimir Vassilevsky rote:

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 to
Roberto Waltman

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.

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

formatting link

Reply to
Vladimir Vassilevsky

Could you identify/use one particular block?

-- Roberto Waltman

[ Please reply to the group. Return address is invalid ]
Reply to
Roberto Waltman

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 to
Don Y

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 to
Roberto Waltman

Are you feeling slightly telepathic? ;)

-- Roberto Waltman

[ Please reply to the group. Return address is invalid ]
Reply to
Roberto Waltman

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 to
Rob Gaddi

Pardon me, Freudian slip...

-- Roberto Waltman

[ Please reply to the group. Return address is invalid ]
Reply to
Roberto Waltman

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)

Reply to
Don Y

I figured the string "Vassilevsky" probably stands a greater chance of reducing those sorts of hits! (there are advantages to having "unique" surnames! :> )

Or, ensure the struct's contents are "checksum neutral" (not possible with all checksum algorithms)

Reply to
Don Y

Ah, my bad. :<

Then, instead, store:

"30A9v ,4.3.21 dliuB ,yksvelissaV rimidalV 11029180 thgirypoC"

which, theoretically, should *program* the entire chip and spray water (halon?) on anyone nearby!!

Reply to
Don Y

That idea almost works... but the maker string could be occasionally broken into two chunks in the boot sequence. So, the flash stream should be interpreted rather then simply searched. If the flash stream has to be interpreted, then I can put a version structure to a predefined location in the target memory map, and everything is simple. Oh, but I don't like writing an interpretor, that's the only problem :-)

Vladimir Vassilevsky DSP and Mixed Signal Design Consultant

formatting link

Reply to
Vladimir Vassilevsky

Does the "(c)Rob Gaddi" string put an ARM processor into an idle mode ?

Actually, I can remember piece of code that started with a text string "Hello my dear friend". That was a computer game for Sinclair Spectrum. IIRC, that translated to a harmless series of relative jumps on Z80 cpu.

VLV

Reply to
Vladimir Vassilevsky

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.