How to program flash through DEMO9S08QG8 by UART command?

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

How to program flash through DEMO9S08QG8 by UART command?

15,433 Views
TonyLin
Contributor I
Hi, I would like to program flash inside HCS08 through DEMO9S08QG8 board in my own application. I need to use UART port to program the flash. I know it can be done by using CodeWarrior. But I need to integrate the flash program into my production software. Anybody know where I can find its programming commands for UART port? Or is there any DLL available to implement it?
 
Thanks!
Labels (1)
0 Kudos
22 Replies

4,313 Views
TonyLin
Contributor I
Hi, has the bootloader for QG8 been released offically? Where can I find it. Thanks!
0 Kudos

4,313 Views
ok2ucx
Contributor IV
not yet, the only "official" release is here, just few messages above. AN2295SW update is in progress, together with USB version for HC908JW32. will go officially out hopefully before end of this year.
 
has anybody had a chance to try this QG8 alpha version of bootloader? either with positive or negative result? please tell me.
 
regards, pavel ok2ucx, an2295 developer's bootloader developer :smileywink:
0 Kudos

4,313 Views
buxi
Contributor I
Hi,

I just tried to use the new boot loader: I created a new project with CW 5.1 and Processor Expert, just toggling PTA0 every second, which works fine. I modified the boot loader to use PTA0/1 for TXD/RXD, starting the PC application, which recognizes the 0xFC and is ready to download the firmware.
However, CW 5.1 adds the following hex records into the file:

S104FFBDFF40
S104FFBF7EBF

It writes into the NVPROT and NVOPT, and the loader warns that this hex file will not fit in to the MCU (QG8). I removed these two records, and the loader programs the firmware without any problems. But the original application does not seems to start.

I compiled the original application, removed the two records, and then started the debugger, to program the MCU with this application but w/o these records. The memory shows 0xFF for FFBD/FFBF and the application works.

Any ideas?

Thanks,

Marco
0 Kudos

4,312 Views
buxi
Contributor I
Hi,

I just wanted to mention one more thing: With removing the two records NVPROT/NVOPT, the PC boot loader still determines the address range of the application between E000 and FDBF. Not quite sure, if this might cause the problem.
Here is the log of the boot loader:

hc08sprg - Developer's Serial Bootloader for HC(S)08 - $Version: 1.0.26.0$
FC protocol versions supported: 1 (HC08), 2 (S08), 3 (large HC08)
See Freescale Application Note AN2295.

Waiting for HC08 reset ACK...hc08sprg - Developer's Serial Bootloader for HC(S)08 - $Version: 1.0.26.0$
FC protocol versions supported: 1 (HC08), 2 (S08), 3 (large HC08)
See Freescale Application Note AN2295.

Waiting for HC08 reset ACK...received 0xfc (good).

Calibration break pulse sent. Count: 1
Bootloader protocol version: 0x02 (read command supported)
Bootloader version string: QG8-softSCI
System device ID: 0x009 [unknown] rev. 2
Number of memory blocks: 1
Memory block #1: 0xE000-0xFDBF
Erase block size: 512 bytes
Write block size: 64 bytes
Original vector table: 0xFFC0-0xFFFF
New vector table: 0xFDC0-0xFDFF

hc08sprg - Developer's Serial Bootloader for HC(S)08 - $Version: 1.0.26.0$
FC protocol versions supported: 1 (HC08), 2 (S08), 3 (large HC08)
See Freescale Application Note AN2295.

Waiting for HC08 reset ACK...hc08sprg - Developer's Serial Bootloader for HC(S)08 - $Version: 1.0.26.0$
FC protocol versions supported: 1 (HC08), 2 (S08), 3 (large HC08)
See Freescale Application Note AN2295.

Waiting for HC08 reset ACK...received 0xfc (good).

Calibration break pulse sent. Count: 1
Bootloader protocol version: 0x02 (read command supported)
Bootloader version string: QG8-softSCI
System device ID: 0x009 [unknown] rev. 2
Number of memory blocks: 1
Memory block #1: 0xE000-0xFDBF
Erase block size: 512 bytes
Write block size: 64 bytes
Original vector table: 0xFFC0-0xFFFF
New vector table: 0xFDC0-0xFDFF

Are you sure to program part? [y/N]:

Thanks,

Marco
0 Kudos

4,307 Views
ok2ucx
Contributor IV
Hi buxi,
 
this behaviour is completely correct. Everything works as expected. Glad to see that even a soft-SCI version works fine. NVOPT/NVPROT as one of the limitations is documented in AN2295, page 22 (fo S08). More precisely:

FLASH Protection Technique Not Usable

The bootloader uses a FLASH block protection technique to protect itself from being overwritten, therefore this feature is not available for the user code. This includes FLASH memory security related registers (namely NVPROT, NVOPT, and NVBACKKEY), which are used for protection and interrupt vector relocation by bootloader.

Basically all Flash above 0xFDBF is occupied by Bootloader. No user code should be present above this address, just except interrupt vectors that are automagically redirected to 0xFDC0-0xFDFF area.

That also explains why bootloader complains about NVOPT and NVPROT memory locations. And it always will. Actually nothing wrong happens, these Flash memory locations are protected and cannot be overwritten. And your values are simply ignored.

Regards, Pavel, ok2ucx

P.S. AN2295 rev. 8 will go officially on web these days. QG8 bootloader already included.

0 Kudos

4,308 Views
buxi
Contributor I
Thanks ok2ucx,

good to know that it's working as expected :smileywink:. But when I left the NVOPT/NVPROT records in the hex file, the boot loader never completed the programming - I had to cancel it out.
I can live with removing these records (or deactivate them in CW 5.1 if I find out how ;-)), but unfortunately my simple application is not working.

Thanks,

Marco
0 Kudos

4,309 Views
buxi
Contributor I
Hi,

little update: Rewrote the simple application w/o the PE and it works.
However, I got the same problem that I had with QB boot loader: It works the first time, because the MCU keeps sending the 0xFC packet. But after the first programming, the MCU only outputs a limited number of packets, before it's switching to the user code.
I added another 100ms time delay in the QB loader to make it work, but I'm not so successful with the QG.

Thanks,

Marco
0 Kudos

4,313 Views
Witya
Contributor I

hey,

 

what is PE  in "Rewrote the simple application w/o the PE and it works."

 

cause I am having similar problem right now

0 Kudos

4,313 Views
ok2ucx
Contributor IV
Hi TonyLin,
 
you probably intend to use Serial Monitor (described in AN2140) for Flash programming. I'm not aware of any stand-alone application that would be capable of inferfacing these commands. The Serial Monitor is primarily intended for low-cost debugging while your requirements are slightly different.
 
I wonder if you could use AN2295SW bootloader for purpose of Flash programming only. Yes, QG8 code has not been released yet but it has been developed 3 weeks ago. If you are interested, find the alpha version code on freegeeks download/utililities area: http://www.freegeeks.net/modules.php?name=Downloads&d_op=viewdownload&cid=1#cat
 
Hope you find it useful.
 
Regards, Pavel, ok2ucx (AN2295 developper)
Freescale Czech System Center,
Roznov p.R., Czech Republic, EU
0 Kudos

4,313 Views
TonyLin
Contributor I
Now the 9S08QGx comes empty from the factory. So I can not use Serial Monitor for initial flash programming. Do you mean it will comes with bootloader for SCI communication in near future?
0 Kudos

4,313 Views
ok2ucx
Contributor IV

Nope,

AN2295 bootloader is an independent software and will not be programmed into shipped devices (as far as I know). Originally it has been intended as a simple help tool for developper for quick flash re-programming and it comes on a as-is basis. Some people actually use it in production allowing end user to update firmware on their own.

The Freescale devices are usually sold blank, in large volumes any user code (e.g. bootloader) can be factory programmed during the final tests. It costs some buck$ but at the end it brings some further savings during manufacturing (design of BDM interface not needed, actual programming does not need to be done, etc.).

Normally, use P&E Micro tools, TBDML, Open Source BDM or alike tools for production programming.

Regards, Pavel (ok2ucx)

Freescale Roznov

0 Kudos

4,314 Views
buxi
Contributor I

Well,

I'm using the AN2295 bootloader on a QB8 uC, but I'm not sure about the "Re"-programming part of that bootloader: It worked fine the first time I'm loading user code with that bootloader, but after that it appears that I can't get back in the "hook" to re-program another user program.
Anyone any idea on why I can't seem to re-program after I programmed my user code?

Anyway.....I also want to switch to the QG8, would love to use this bootloader (if I can make it work), but the SCI is not included in the 8 pin package, so I'll have to port the code to IIC on the uC, use a SCI-IIC bridge (e.g. a uC with both interfaces like the GB60A). This way, the PC won't know about the different interface, the GB60A is bridging data from the IIC and SCI, I just have to work on the IIC.
Btw: I got a message from Freescale support stating that they won't have the porting to 8 pin QG8 until May 2006.

  buxi

 

0 Kudos

4,314 Views
ok2ucx
Contributor IV

Hi,

re-programming should definitely work, it's a main feature. If initial hook won't occur once there's some code already in the MCU, it may be caused by RS232 level shifters not properly working fast enough after power-on. Then PC won't see initial ACK from the micro.

To confirm this, try to use RESET pin of QB8 (if enabled) or power RS232 shifters from separate supply (dirty way is to short-connect MCU Vdd for a short while).

For 8-pin QG8, porting code to IIC would be a huge effort instead of adding software SCI functionality (that was me promissing doing it in May ; ). Similar way like on QT/QY family. Once this alpha software is available, I'll let the forum know.

Regards,

Pavel, ok2ucx

Freescale Roznov, AN2295 author

0 Kudos

4,314 Views
buxi
Contributor I
 
Okay, May is just around the corner...hope it's gonna be begin of May though :smileywink:.
 
As for the re-programming....it's now working. I'm sure you're right with the level shifters: I've added another 100ms delay _before_ the uC is looking for hook data, giving more time to find the hook, and it's working fine now.
 
Thanks,
 
 Marco
0 Kudos

4,314 Views
ok2ucx
Contributor IV

Hi,

I've just finished alpha version of software SCI bootloader for S08QG family. It has been briefly tested using demo board. Works up to 57600Bd. I haven't tested a single wire feature since I have no hardware setup quickly available.

Please find the source files in freegeeks download section:

http://www.freegeeks.net/modules.php?name=Downloads&d_op=viewdownload&cid=1#cat

All comments please via personal messages.

Nice weekend,

Pavel, ok2ucx
Freescale Roznov p.R., CZ

AN2295 bootloader developer

 

0 Kudos

4,314 Views
ok2ucx
Contributor IV

Hi guys,

just for convenience I've attached both versions of S08QG bootloaders here before they go officially into AN2295SW. Note that both versions of QG8 bootloaders are in alpha version, any bugs should be reported to me (preferrably via personal message). Thanks.

'Standard' version uses hardware SCI module, second emulates SCI using software (good for 8-pin device and/or if you want to use another pin or single-wire communication).

Regards, Pavel ok2ucx

Developer of AN2295 HC(S)08 Developer's Bootloader

 

hc08sprg-s08qg-alpha1-bootloaders.zip

Message Edited by t.dowe on 2009-09-03 05:33 PM
0 Kudos

4,313 Views
PaoloSchiappaca
Contributor I

Hello, do you know if there is available the single wire bootloader for 9S08QGx via hardware SCI!?!

 

I've only found the software version, while the hw one is available for other 9S08's

 

 

Regards

 

 

Paolo

0 Kudos

4,313 Views
buxi
Contributor I
Hi,

I was just wondering, if anyone had a chance to implement the new bootloader, and if there are any problems so far.

Thanks,

Marco
0 Kudos

4,313 Views
buxi
Contributor I
I was actually thinking about using another uC to inface the QG8 to SCI (PC), basically have the uC relay data between IIC and SCI. The problem here is that I'd need two wires (SCA,SCL), whereas with an emulated SCI I might get away with one wire. Would that be possible?
 
Thanks,
 
  Marco
0 Kudos

4,313 Views
peg
Senior Contributor IV

Hi Marco,

Why are you going to so much trouble to avoid using a BDM based solution?

To me the only reasons for using a serial bootloader are:

1: You can't afford a BDM based device.

2: You want to enable field upgrades with just a serial cable (presuming the user in the future can find a serial port!)

I can see no reason to bother to build a piece of hardware to avoid the BDM solution.

You could build the OSBDM.

BR Peg

 

0 Kudos