internal EEPROM programming through SWD/JTAG and/or ISP

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

internal EEPROM programming through SWD/JTAG and/or ISP

3,016 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by giusloq on Wed Jul 22 07:00:22 MST 2015
Is it possible to program some values in the internal EEPROM of LPC1778 part, during SWD/JTAG and/or ISP programming?

I think it isn't possible, but I'd like a confirmation.
Labels (1)
0 Kudos
16 Replies

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by giusloq on Mon Dec 14 00:58:25 MST 2015

Quote: MikeSimmonds
However note that the (physical) flash is divided into sectors (regardless of how few bytes you assign).
Programming the 4 (or whatever) bytes causes the entire sector (32K, 64K?) to be erased.



What's the problem? I write the serial number together with the application (and maybe the bootloader), so the first operation is a "chip erase".
0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Sat Dec 12 09:20:34 MST 2015
Whatever works for you.  :)

However note that the (physical) flash is divided into sectors (regardless of how few bytes you assign).
Programming the 4 (or whatever) bytes causes the entire sector (32K, 64K?) to be erased.

Cheers, Mike.
0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by giusloq on Sat Dec 12 08:42:09 MST 2015

Quote:
Well here is a sample assembler module
[...]
Reference section '.serial' in your linker script.
There is also a linker (ld) manual via the help.



I use LPCXpresso that manages automatically the linker script. So I obtained the same result changing the memory layout from Memory Editor Window (or a similar name) reached with Project->Properties...
I split the Flash section in two sections. The second section occupy only the last 4 bytes of the Flash memory and it is where the serial number will be saved.

In C code, I use macros in <cr_sections_macro.h> to specify the section of a const uint32_t variable. See this link.

In the programming script, after obtaining a new serial number (I'm using a simple .csv file), I create the image file from the original image file using the powerful SRecord tool.
0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Fri Dec 11 09:39:12 MST 2015
I have given all the techniques; you will have to handle the details yourself.
Because I cannot show any details as they are company confidential.

Well here is a sample assembler module
in .section, "a" means allocatable, "%progbits" means generate output (not just space)
See the GNU assembler manual via the IDE help.
You can probably do the same thing in "C" via the various pragmas. There even threads here if you search.
But I prefer the assembler route, so have no details.

File: Serial.s:
.file"Serial.s"
.globalSerialNumber

.section .serial, "a", %progbits
.align 4,0

.type SerialNumber, %object
.size SerialNumber, 4

SerialNumber:.word 0xFFFFFFFF


Reference section '.serial' in your linker script.
There is also a linker (ld) manual via the help.

Cheers, Mike.
0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Fri Dec 11 09:27:22 MST 2015
No tool to patch as such,

The actual patching is done in the code that downloads to the device
after reading the input (un-serialised) download image and
before transferring to ram prior to copy-ram-to-flash.

Cheers, Mike.
0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by giusloq on Fri Dec 11 02:56:08 MST 2015

Quote:
We do not consider speed to be an issue (no measurements were made) as this is a one-off operation.


If your market is low-volume high-profit, this is right. When you work with high-volume and low-profit devices, a fast programming procedure means money.


Quote:
'Patch in' simply means the a defiined address of the download image (set to all FF's in the source code)
is overwritten with a 'value' before the download process begins.


Now I understand, you use Flash to store serial number, not EEPROM. It is a good solution.

Do you use any tool to 'patch' the download image file (I think you use output .bin)?


Quote:
I had a small assembler module to define the value (as 0xFFFFFFFF) and used the linker script
to place it at a defined location.

Read the docs if that is unclear.


I understand the method you use, but I don't know how to make it. Please, could you share your assembler and linker script? Thank you.
0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Thu Dec 10 18:40:51 MST 2015
We do not consider speed to be an issue (no measurements were made) as this is a one-off operation.

'Patch in' simply means the a defiined address of the download image (set to all FF's in the source code)
is overwritten with a 'value' before the download process begins.

'Value' is just that -- a number -- and can mean whatever you want. In our case a serial number.

This 'value' can be read at any time by simply forming a pointer to the address and de-referencing it.
Just like any constant coded in to flash.

#define SerialAddr   0x0100
unsigned long *pSerial = (unsigned long *) SerialAddr;
mySerial = *pSerial;


This is just basic "C".

The actual address (0x100) is just an example.
I had a small assembler module to define the value (as 0xFFFFFFFF) and used the linker script
to place it at a defined location.

Read the docs if that is unclear.

Mike.


0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by giusloq on Thu Dec 10 07:20:10 MST 2015

Quote:
Essentially I wrote a PC app that uses the ISP command set to handle the same functions that FlashMagic would.


Isn't ISP much slower than SWD in Flash programming?


Quote:
and to 'patch in' a serial number


What do you mean with "patch in"? Is your final application responsible to read/accept the serial number from UART at first power up, using a proprietary protocol?
0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Thu Dec 10 06:51:23 MST 2015
At our place, we use the UART and ISP.

Essentially I wrote a PC app that uses the ISP command set to handle the same functions that FlashMagic would.

It is tailored to get the flash image automatically (there is only one we use) and to 'patch in' a serial number
on the fly for every download.

The next serial nbr was maintained in an ini file with the 1st version, now we use a SQLite database with
that and other info.

Cheers, Mike.
0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by giusloq on Thu Dec 10 04:31:39 MST 2015

Quote:
But if I use SWD to program this EEPROM manager in RAM, must I switch to another port (UART) for communixations between host and target?
Is it possible to use SWD to exchange data between the appication running from RAM in the target MCU and the PC?

If I need to switch to a regular UART, I implement the code to write in EEPROM directly in the final application that uses that port.



No one answered to this question.

My goal is to write a serial number in EEPROM during Flash programming. I use SWD debugger/programmer (J-Link) to program Flash memory. I'd like to use the same connection to program the serial number too, without using another communication port.

Is it possible? Any idea?

Thank you.
0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by giusloq on Wed Jul 22 11:39:09 MST 2015
Ok, ok.

But if I use SWD to program this EEPROM manager in RAM, must I switch to another port (UART) for communixations between host and target?
Is it possible to use SWD to exchange data between the appication running from RAM in the target MCU and the PC?

If I need to switch to a regular UART, I implement the code to write in EEPROM directly in the final application that uses that port.
0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Wed Jul 22 09:26:49 MST 2015
Yes - In the same way that it knows where to place it when flash is defined - read the linker script...
0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by giusloq on Wed Jul 22 09:04:19 MST 2015

Quote:
SImplest way to do this is to use the Memory editor and delete all of the flash!


Thank you for your suggestion.

How the linker know where to put the code? Does it automatically put the code in RAM when there isn't Flash memory sections?

What will be the address of the entry point of the application in RAM? Is it 0x10000000, the first location of RAM in LPC1788?
0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Wed Jul 22 08:41:20 MST 2015
SImplest way to do this is to use the Memory editor and delete all of the flash!
0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by giusloq on Wed Jul 22 08:31:02 MST 2015

Quote:
You could very easily download a small code image to SRAM via ISP or JTAG/SWD and execute that to program the EEPROM or anything else for that matter.


Good suggestion. But I need some help.

Do you have a reference for an "all in RAM" LPCXpresso starting project?
0 Kudos

2,498 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Wed Jul 22 07:51:04 MST 2015
You could very easily download a small code image to SRAM via ISP or JTAG/SWD and execute that to program the EEPROM or anything else for that matter.

Mike.
0 Kudos