Simple Serial Numbering JIT module for LPC2378

Started by Torben W. Hansen, February 05, 2009, 04:41:21 AM

Previous topic - Next topic

Torben W. Hansen

Hi,

I have rewritten the "JIT Examples/Simple Serial Number"  C-code, which follows the FlashMagic tool, in order to work with the ARM based LPC2378 cpu. The original C-code was limitted to program the serial number in a 16bit flash address range (0x0000...0xFFFF) for the 8051 family. It is now possible to program a "Just In Time serial number" into the full 32bit flash address range (0x00000000...0x0007FFFF), which requires use of INTEL HEX record types 4 and/or 5. The C-code is still working for 16bit address ranges as 8051s.

The modified C-code works perfectly, but I do not fully understand some few parts of the original code. I have studied the Flash Magic User manual and found only a little about JIT modules.

In the original C-code file pointers and arrays below are defined:

  FILE *commandfile;
  FILE *datafile;
  FILE *userfile;
  char datafilepath[2000];
  char userfilepath[2000];

In the User manual for FlashMagic on page 50/51 under the section "7.5 Just In Time Code" following is written:

executablename
commandfilepath
datafilepath
userfilepath
option

My questions are:

1) Can somebody explain the connection between these terms and the C-variables ?

2) I can't find any .hex file generated by the serial numbering JIT module.
    Is the serial number hex information placed in a file or generated by FlashMagic on the fly ?

If it is of interest for this forum I can upload the modified Serial number JIT module including source code to this web site...

Kind Regards
Torben W. Hansen




Andy Ayre

When Flash Magic calls the JIT module it passes the path to a command file. This command file is a text file that contains two paths. The first is for the data file and the second is for the user file.

The JIT module places the hex records in the data file and the user output in the user file.

When the JIT module has finished executing Flash Magic programs the contents of the data file and displays the contents of the user file to the user. Flash Magic then deletes the data file and the user file.

Before calling the JIT module Flash Magic generates temporary paths for the data file and the user file.

I hope this answers your questions.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

Torben W. Hansen

Thanks!

It was an excellent answer.

Can I find information of the data and user files in the command file and in which folder is the command file located ?

Kind regard
Torben W. Hansen

Andy Ayre

The command file is stored in the windows temporary folder. The paths assigned to the data and user files are also stored in the windows temporary folder. As Flash Magic deletes all of these when the JIT module finishes the best point to output debugging information and examine these files is in your JIT module.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

Torben W. Hansen

Dear Andy,


Thanks for your information!

Have nice weekend...

Kind regards
Torben W. Hansen

Andy Ayre

Torben's JIT module is now available from our resources section:

http://www.flashmagictool.com/resources.html

Thanks Torben!

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

urosg

I don't know if I'm doing something wrong or this just doesn't work for me.

I get the serial number in the message box when flashing with FlashMagic and also the file "serialnumbers.txt" is updated, but in number written in flash is not the same as the serial number generated.
...

And while playing around with FlashMagic I just found out when it does and when it doesn't work.

It does work if I DON'T have the "Erase blocks used by Hex file" checked, but if I check this then the "serial" is not written as generated.

How could this be solved?

Andy Ayre

The Erase Blocks Used By Hex File option will only erase the blocks used by the hex file you select. So if your serial number is in a different block then it won't be erased. Try this simple test:

Go to ISP -> Erase Flash... and erase the entire flash memory.
Go to ISP -> Display Memory... and make sure the serial number location is erased.
Check "Erase blocks used by Hex File".
Program your hex file and run the JIT module.
Go to ISP -> Display Memory... and make sure the serial number was programmed.

Was it? I tried this myself with Flash Magic 4.61 and it worked for me.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

Andy Ayre

My suggestion is to reserve four bytes at a specific location in your application for your serial number, then use that location in the JIT module configuration. This will ensure that the serial number is at a fixed location and in one of the blocks used by your hex file.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

urosg

Yes if I erase complete flash then it works as it should.

I have declared the var in my code as "unsigned int *serialNum = (void * )0x0007D000;" and it gets read by the program, but writing of the value to flash is still the problem unless I erase complete flash.

Should I declare anything else?

thanks!

Andy Ayre

You have to make sure that the locations you are programming the serial number to are erased. So either:

1. Move the serial number into one of the blocks used by your hex file

2. Erase the block containing the serial number by selecting it or erasing all flash

However this is only needed for development because on the production line the flash in new devices is already erased.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com