Can USBDM program to ROM space?

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

Can USBDM program to ROM space?

1,341 Views
tyamadajp
Contributor I

Hi.

 

While testing out USBDM, I noticed I couldn't program the chip which used banked memory region.

Specifically, I'm working with MC9S12NE64 chip right now, and this chip has following memory map:

 

MCU space ---(maps to)--> ROM space--------------------------------------------0x0000-0x3FFF             none (MCU space has registers/RAM)0x4000-0x7FFF             0x8000-0xBFFF0x8000-0xBFFF             bank switched with PPAGE to:                          - 0x0000-0x3FFF                          - 0x4000-0x7FFF                          - 0x8000-0xBFFF                          - 0xC000-0xFFFF0xC000-0xFFFF             0xC000-0xFFFF

 

It seems USBDM tries to program the chip using MCU memory space, so it cannot program to any of banked region, hidden from MCU space. I worked around the issue by writing custom programming tool using the USBDM API.

 

This is kind of problematic (at least confusing), as this means memory map is completely different depending on what tool you use to program the chip. Since flash programming based on ROM space is more generic (it can access all parts of memory space), it may be useful to add a new programming mode to HCS12_FlashProgrammer.

 

I'm not sure about other chip types, but if they have banked memory system, they may also have similar issue.

 

I'm planning to either post a patch or upload my custom programming tool, so other people can use it. I guess patch would be a better idea, but I currently do not have environment to rebuild USBDM on Linux as I'm not familiar with build system / source code structure of USBDM.

Tags (2)
0 Kudos
3 Replies

743 Views
pgo
Senior Contributor V

Dear tyamadajp,

 

The USBDM programmers (HCS08/HCS12) can program to banked memory spaces or to linear address spaces where the target supports that mode (e.g.P128).

 

The memory map used is that given in the manual for the chip.  I've attached the relevent page from the NE64 manual.

 

This mapping has been tested on a NE64 chip and corresponds to that generated by the Codewarrior tools.

 

It is possible to generate arbitrary mappings by creating new entries in the XML files that describe the target chip.

 

Can you provide some references to compilers or tools that generate linear ROM maps?

 

The relevent entries from the USBDM device file (hcs12_devices.xml) for NE64 are:

 

      <device family="HCS12" name="MC9S12NE64">         <clock type="External" />         <memory type="ram">            <memoryRange end="0x1FFF" start="0x0400" />         </memory>         <memory pageAddress="0x0030" registerAddress="0x0100"
                        type="flash" securityAddress="0xFF00">            <securityInfoRef ref="HCS12-default-security-off" />            <securityInfoRef ref="HCS12-default-security-on" />            <memoryRange end=  "0x7FFF" start=  "0x4000" /> <!--  0x3E -->            <memoryRange end="0x3CBFFF" start="0x3C8000" />            <memoryRange end="0x3DBFFF" start="0x3D8000" />            <memoryRange end="0x3EBFFF" start="0x3E8000" />            <memoryRange end="0x3FBFFF" start="0x3F8000" />            <memoryRange end=  "0xFFFF" start=  "0xC000" /> <!--  0x3F -->         </memory>         <sdid value="0x8200" />         <sdid value="0x8201" />         <flashProgramRef ref="HCS12-MMCV4-FTS-flash-program" />      </device>

 

bye

0 Kudos

743 Views
tyamadajp
Contributor I

Hi pgo!

 

Thanks for the pointer. Toolchain is gcc-hc1x (obtained from http://www.msextra.com/tools).


GCC-HC1X toolchain does not come with good linker script, and by default, is uses linear map of 0x4000-0xFFFF. It does work, but in order to use hidden banked region, it's up to each user to write custom linker script.

 

Since GCC has  "far" calling convention (gcc-hc1x FAQ) which maps VMA (MCU space) address of 0x100000- to proper CALL/RTC pair with automatic PPAGE bank switching,  I initially mapped banked region to 0x100000-0x10FFFF, but that also making LMA (ROM space) address to be the same by default.

 

With your post, now I finally understood LMA addressing convention of CodeWarrior/USBDM programmer, so I updated my linker script to define banked region with VMA:0x10XXXX, LMA:0x3[CDEF]XXXX. With this updated configuration, I was able to use HCS12_FlashProgrammer to program generated binary.

 

Best Regards,

0 Kudos

743 Views
tyamadajp
Contributor I

Just FYI to other gcc users, LMA offset needed to support "far" call seems to differ by which version/patch is applied to your gcc.

 

In the FAQ page above, it is said it's either 0x1000000 or 0x10000, but it turned out to be 0x100000 in my environment Smiley Sad.

 

$ m9s12x-elf-gcc -vReading specs from /usr/lib/gcc-lib/m9s12x-elf/3.3.6-9s12x-20101028/specsConfigured with: ../../gcc-3.3.6-s12x/configure --target=m9s12x-elf --prefix=/usr --program-prefix=m9s12x-elf- --enable-languages=cThread model: singlegcc version 3.3.6-9s12x-20101028

 is the gcc version I'm using.

0 Kudos