Creating a S record that will be downloaded to Flash memory HCS12 using TwinPEEKs monitor

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

Creating a S record that will be downloaded to Flash memory HCS12 using TwinPEEKs monitor

5,377 Views
Sarroyo
Contributor I
I am using a CardS12 from Elektronik Laden.  Onboard it carries a MC9S12DP512.  It has a monitor called TwinPEEK's that has been preinstalled in the Microcontroller.  I have been able to successfully download s records directly to ram.  I am trying to create a s record that can be dowloaded into the internal flash.  I am a bit confused about memory paging and the physical addresses of each page.  Nevertheless everytime I try The monitor says "invalid s Record".  Here is all the information I have from the manual. 

Load an S-Record file into memory. Data records of type S1 (16-bit MCU addresses) and S2 (linear 24-bit addresses) can be processed.  S0-Records (comment lines) will be skipped. S8- and S9-Records are  recognized as end-of-file mark. S2-Records use linear adresses according to Freescale guidelines.  The valid address range for the MC9S12D64 starts at 0xF0000 (0x3C * 16KB) and ends at 0xFFFFF (0x40 * 16 KB - 1).

Keep in mind that I am using the MC9s12DP512.  What steps do I need to take to progam to Flash memory?

Labels (1)
0 Kudos
14 Replies

1,842 Views
CrasyCat
Specialist III
Hello
 
Here the question is which format does the TwinPEEKs monitor support?
How is it expecting banked addresses to be encoded?
 
THere seems to be some restriction in the loader. As long as you cannot find a clear description of what is expected we will not be able to help you more.
 
Sorry.
 
CrasyCat
0 Kudos

1,842 Views
Sarroyo
Contributor I
I posted all the information available about the TwinPEEKs monitor in the initial comment I made.    I ommited the following informatino because I am not getting a "write error".  Let me know if you have any ideas!  Thanks
 

The CPU can read every single byte of the microcontroller's resources - the type of memory does not matter. However, for write accesses, some rules have to be followed: Flash and EEPROM have to be erased before any write attempt. Programming is done by writing words (two bytes at a time) to aligned addresses.  To form such aligned words, two subsequent bytes have to be combined. TwinPEEKs is aware of this, but the following problem can not be avoided by the monitor: The monitor is processing each S-Record line seperately. If the last address of such an S-Record is even, the 2nd byte to form a complete word is missing. TwinPEEKs will append an $FF byte in this case, so it is able to perform the word write. The problem occurs, if the byte stream continues with the following S-Record line. The byte, that was missing in the first attempt, CardS12 28 would require a second write access to the same (word) address - which is not allowed. As a consequence, a write error ("not erased") will be issued. To avoid this problem, it is necessary to align all S-Record data before programming. This can be done using the freely available Freescale Tool SRECCVT:

SRECCVT -m 0x00000 0xfffff 32 -o <outfile> <infile>

A detailed description of this tool is contained in the SRECCVT Reference Guide (PDF). Please note, that it is not possible to program or erase the part of Flash memory that contains the monitor code. Also, the last 16 bytes of the EEPROM block are reserved for system use.

 

0 Kudos

1,842 Views
CrasyCat
Specialist III
Unfortunately this does not explain what the TwinPEEKs monitor expect as S record file.
Apparently it supports only a sub-set of the S record format.
 
Can you please contact the provider of this monitor and get a clear picture of what the monitor is expecting.
 
Basically I need answer to following questions:
  - Does the monitor support programming of banked flash?
  - Does the monitor support S1, S2 and S3 records or only S2?
  - Does the monitor support S0 records
  - Which address is the monitor expecting for code located at address 0x4000? 
  - Which address is the monitor expecting for code located at address 0xC000? 
  - Which address is the monitor expecting for code located at address on bank 0x20 at address 0x8000?
  - Which address is the monitor expecting for code located at address on bank 0x30 at address 0x8000?
 
Knowing that I can surely adjust the .bbl file to generate something the monitor can handle.
 
CrasyCat
0 Kudos

1,842 Views
Sarroyo
Contributor I
All that was included in the manual is shown below.  I will email where i purchased the item to get some more info.  Thanks!
 
Data records of type S1 (16-bit MCU addresses) and S2 (linear 24-bit addresses) can be processed.  S0-Records (comment lines) will be skipped. S8- and S9-Records are  recognized as end-of-file mark. S2-Records use linear adresses according to Freescale guidelines.  The valid address range for the MC9S12D64 starts at 0xF0000 (0x3C * 16KB) and ends at 0xFFFFF (0x40 * 16 KB - 1).
 
CardS12.DP512
Begin     End     Resource
$0000   $03FF  Control Registers
$0400   $07FF  1KB (of total 4KB) EEPROM, (the area below $0400 is hidden
                       by control registers the top 2048 bytes by the RAM!)
$0800   $3FFF  14KB RAM - TwinPEEKs uses the top 512 bytes
$4000   $7FFF  16KB Flash (equals Page &3E)
$8000   $BFFF  16KB Flash page $20 (any Page $20...$3F, selectable)
$C000   $FFFF  16KB Flash ( equals Page $3F) TwinPEEKs uses the top 4KB

Note:

Due to a mask set erratum of the MC9S12DP512 Mask Set 4L00M (and earlier) not only the monitor code in page $3F is write protected, but also an additional area starting at $B000 up to $BFFF in page $3B. Consequently, the monitor can not download user code to this region.

0 Kudos

1,842 Views
Sarroyo
Contributor I
I FIGURED IT OUT!!!!!   WHOo hoo, geeze It turns out that I needed to specify 16 for the s-record size, when using SRecCvt.  I looked at the s-record that the program IAR was producing, and compared it to the Codewarrior s-record.  That was the major difference!  And Now it works like a charm.  Oh I spent way to much time on that.  Thanks for the tip on the .phy files, cuz that is the file i converted with SRecCvt.  Rock on!!
0 Kudos

1,842 Views
CrasyCat
Specialist III
Hello
 
OK in that case the limitation was in the length of a S record line.
You can also adjust that directly in the project .bbl file.
 
Just add following line to the .bbl file 
    SLINELEN = 16
 
This line should be added after the comment
/* physical s-record file */
on line 12.
 
CrasyCat
0 Kudos

1,842 Views
J2MEJediMaster
Specialist I
OK, it seems you have a question about the HC(S)12's paged memory and the page registers. There's a forum thread here that discusses banked memory with a mention of Flash memory programming. Another thread is a discussion of paging with respect to the GPAGE and PPAGE registers. What type of S records are you generating?

HTH,

---Tom
0 Kudos

1,842 Views
Sarroyo
Contributor I
Wow thats pretty deep.  Well I am shooting for a s1 record, or a s2 whichever is easier.  I would like to make this as simple as possible, and get more advanced once I have the basics down.  Take a look at my prm file.
 
NAMES
END
SECTIONS
   RAM        = READ_WRITE 0x0800 TO 0x1799;
   PSEUDO_ROM = READ_ONLY  0x1800 TO 0x3fff;
   //FLASH      = READ_ONLY  0xC000 TO 0xEFFF;
END
   
PLACEMENT
   _PRESTART, STARTUP,
   ROM_VAR, STRINGS,
   NON_BANKED,DEFAULT_ROM,
   COPY                   INTO   PSEUDO_ROM;
   DEFAULT_RAM            INTO   RAM;
END
STACKSIZE 0x100
 
This works like a charm, but it is to Ram only.  As you can see i have commented my attempt at a simple flash definition.  When I copy into the flash i get "Invalid S record!"  After every attempt I take a look at page 3F, and the first two lines (8000-801F) contain fresh data, and the rest is untouched.  Heres what my bbl looks like
 
OPENFILE "%ABS_FILE%.s1"
format=motorola
busWidth=1
origin=0
len=0x10000
destination=0
SRECORD=S1
SENDBYTE 1 "%ABS_FILE%"
CLOSE
 
l hope this helps.  Also, what non-volitile memory will my processor have while its running?  I want to be able to save some data from the GPIO on the HCS12 while its running, and not have to worry about loosing the data if power is lost.
 
0 Kudos

1,842 Views
CrasyCat
Specialist III
Hello
 
Not sure I understand the question here.
You are looking for a way to generate a S record file for a banked application. And you need all addresses in the S record file to be physical addresses.
Am I right?
 
If this is the case, this should be supported right out of the box by CodeWarrior wizard projects.
If you have created your project using the project wizard, after you built your application you get several files generated in the bin sub directory.
 
  .abs.s19 is a S record file containing logical addresses (non-linear)
  .abs.phy is a S record file containing physical addresses (linear).
 
If I understand the problem well, you need to use the file  with extension .abs.phy.
 
If this one is not working, check with your Hardware provider what S record format is expected from the monitor for banked code.
 
I hope this helps. 
CrasyCat
0 Kudos

1,842 Views
Sarroyo
Contributor I
CrasyCat- Thanks for the Tip, I had no Idea what the .phy file were for.  I have a bunch of wizards saved from failed attempts at downloading to flash.  I tried each one of them to no avail!  I checked the flash location to where it was trying to download saw this 
 

Press Y to erase FLASH Y
20>l
Loading...
**
Invalid S-Record!
20>FEC02914
Argument missing!
20>b
Flash not erased - PPAGE=3F!
20>p 3f
PPAGE=3F
3F>d
8000 <FE>C0 33 FD C0 31 27 0E 35 ED 31 EC 31 69 70 04  <..3..1'.5.1.1ip.>
8010  34 FB 31 03 26 F2 FE C0 35 EC 31 27 0B ED 31 18  <4.1.&...5.1'..1.>
8020  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  <................>
8030  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  <................>
 
 
 

Press Y to erase FLASH Y
20>l
Loading...
**
Invalid S-Record!
20>FFC0164A8004204BFB000320EE0080002010FF0000C02AC030000074
Argument missing!
20>2C0000C02CFFFF0000000000003A
Unknown command (H for Help)!
20>d
8000 <10>EF 20 FE FE C0 1A FD C0 18 27 0E 35 ED 31 EC  <.. .......'.5.1.>
8010  31 69 70 04 34 FB 31 03 26 F2 FE C0 1C EC 31 27  <1ip.4.1.&.....1'>
8020  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  <................>
8030  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF  <................>
 
Hmm......
0 Kudos

1,842 Views
J2MEJediMaster
Specialist I
OK, referring to your documentation, an S1 record only supports 16 bit addresses. If you're going to use banked memory, that requires larger addresses, as described those forum links I provided you. That requires the use of S2 records, I would think.

Checking your RAM-based linker file, the address ranges you use fall with 16-bit address limit, and so the S1 records you use in your BBL file works.

Is the toolset generating only S1 records? Then check the compiler settings and change them to generate banked memory code (-Mb for Codewarrior in the Compile for HC12 Settings panel). See if S2 records appear. Also, you may want to try to change the BBL file to specify a S2 record.

HTH,

---Tom
0 Kudos

1,840 Views
Sarroyo
Contributor I
For this BBL configuration it will only generate s1 records, which download directly to ram with ease. I changed it to s2 records, but when I tried to load it, I got the message "invaild S-Record".,  The same thing happend when I specified -Mb.
0 Kudos

1,842 Views
Alban
Senior Contributor II
May I dare adding to the excellent explanations from Tom and CrazyCat this small document explaining differences between S1, S2 and all... ?
 
OK, I dare.
See pdf enclosed.
 
Also, FSL has a tool available on the web called S-Record Converter to go from one to another !
SRECCVTSW | zip
The zip file contains the .exe file and documentation for SRecCvt; a command line tool for the conversion and reformatting of Freescale S-Record object files. Also included is a GUI interface to the command line tool for Windows and Mac OSX.
 
Cheers,
Alban.
0 Kudos

1,842 Views
Sarroyo
Contributor I
Alban- Thanks for the file.  Good info on the S-records.  I have successfully converted s-records to linear or banked, but I am getting the same error when downloading to flash.  I know I can download to flash as I have been able to using a program called IAR.  I really dont want to transfer all my code to that editor, so I will continue d-bugging in ram, and keep tryin to figure this out.
0 Kudos