instructions: first, type make to build the pkernel. ignore the
warnings.
then start frprog.py and ram pkernel into ram:
> ./frprog.py pkernel/pkernel.mhx
when its done, the first led should be on. next command:
> ./pkernel/kernel.py <your target mhx file>
wait and have fun :D
# let the fun begin!
for seq in flashseqs:
# let the fun begin!
for seq in flashseqs:
- if(seq.address >= 0x148000):
+ if(seq.address <= 0x40000):
+ addr = seq.address
+ else:
- print "RAMing", len(seq.data), "bytes at address", hex(seq.address)
- cmdWRITE(seq.address - flashseqs[0].address + 0x30000, len(seq.data), seq.data)
+ print "RAMing", len(seq.data), "bytes at address", hex(addr)
+ cmdWRITE(addr, len(seq.data), seq.data)
cmdCALL(0x30000);
sys.exit(0)
cmdCALL(0x30000);
sys.exit(0)
LDFLAGS += -ra D_RAM=0x0002C000/0x0002FFFF
LDFLAGS += -ra ID_RAM=0x00030000/0x00031FFF
LDFLAGS += -ro ROM_AREA=0x00080000/0x000FFFFF
LDFLAGS += -ra D_RAM=0x0002C000/0x0002FFFF
LDFLAGS += -ra ID_RAM=0x00030000/0x00031FFF
LDFLAGS += -ro ROM_AREA=0x00080000/0x000FFFFF
-LDFLAGS += -sc DATA/Data+INIT/Data+SSTACK/Data=D_RAM
-LDFLAGS += -sc IRAM/Code=ID_RAM
-LDFLAGS += -sc CODE+@INIT+@IRAM=ROM_AREA
-LDFLAGS += -sc CODE_START/Code=0x000F4000
+LDFLAGS += -sc DATA/Data+SSTACK/Data=D_RAM
+LDFLAGS += -sc CODE_START/Code+CODE=ID_RAM
LDFLAGS += -check_locate -pl 60 -pw 132 -Xals
LDFLAGS += -check_locate -pl 60 -pw 132 -Xals
-LDFLAGS += -Xalr -na -w 1 -Xdof -Xset_rora -cwno -a $(CPUT)
+LDFLAGS += -Xalr -na -w 1 -Xdof -Xset_rora -Xcwno -a $(CPUT)
LIBRFLAGS = -dt s,d,r,a -pl 60 -pw 132 -cwno $(CPUT)
LIBRFLAGS = -dt s,d,r,a -pl 60 -pw 132 -cwno $(CPUT)
+CONVFLAGS = -Xcwno -Xdof
static unsigned int IFlag;
static unsigned int IFlag;
-#pragma section CODE=IRAM,attr=CODE
-
-
void FLASH_PrepareWriteHalfWordMode()
{
/* Set FLASH Access Mode via BootROM Routine */
void FLASH_PrepareWriteHalfWordMode()
{
/* Set FLASH Access Mode via BootROM Routine */
#include "mb91465k.h"
#include "flash.h"
#include "mb91465k.h"
#include "flash.h"
-#pragma section CODE=IRAM,attr=CODE
-
#define BUFSIZE 0x20
#define cleardata() memset(data,0,BUFSIZE)
#define BUFSIZE 0x20
#define cleardata() memset(data,0,BUFSIZE)
1.00 UMa Initial Version
-----------------------------------------------------------------------------*/
1.00 UMa Initial Version
-----------------------------------------------------------------------------*/
-#pragma section CODE=IRAM,attr=CODE
-
#define __IO_DEFINE
#include "mb91465k.h"
#define __IO_DEFINE
#include "mb91465k.h"
; Check the stack information files (*.stk) in the LIB\911 directory.
;
;=========================================================================================
; Check the stack information files (*.stk) in the LIB\911 directory.
;
;=========================================================================================
-; 4.4 Copy code from Flash to I-RAM
-;=========================================================================================
-;
-#set I_RAM ON ; <<< select if code in section IRAM
-; should be copied
-; If this option is activated code located in the section IRAM is copied during startup
-; from ROM to the instruction-RAM. The code is linked for the instruction-RAM.
-;
-;=========================================================================================
; 4.7 Clock Configuration
;=========================================================================================
;=========================================================================================
; 4.7 Clock Configuration
;=========================================================================================
;=========================================================================================
;=========================================================================================
.export __start
.import _main
;=========================================================================================
.export __start
.import _main
- .import _RAM_INIT
- .import _ROM_INIT
;=========================================================================================
; 6.1 Define Stack Size
;=========================================================================================
;=========================================================================================
; 6.1 Define Stack Size
;=========================================================================================
+ .section DATA, data, align=4
.SECTION SSTACK, STACK, ALIGN=4
#if STACK_RESERVE == ON
.EXPORT __systemstack, __systemstack_top
.SECTION SSTACK, STACK, ALIGN=4
#if STACK_RESERVE == ON
.EXPORT __systemstack, __systemstack_top
;=========================================================================================
; 6.2 Define Sections
;=========================================================================================
;=========================================================================================
; 6.2 Define Sections
;=========================================================================================
- .section DATA, data, align=4
- .section INIT, data, align=4
- .section IRAM, code, align=4
-
-#if I_RAM
- .import _RAM_IRAM
- .import _ROM_IRAM
-#endif
+ .section CODE, code, align=4
;-----------------------------------------------------------------------------------------
; MACRO Clear RC Watchdog
;-----------------------------------------------------------------------------------------
; MACRO Clear RC Watchdog
LDI #0x4C7,R7 ; clear RC watchdog
BANDL #0x7,@R7
#endm
LDI #0x4C7,R7 ; clear RC watchdog
BANDL #0x7,@R7
#endm
- .section CODE, code, align=4
.section CODE_START, code, align=4
.section CODE_START, code, align=4
-#pragma section CODE=IRAM,attr=CODE
;=========================================================================================
; 7. S T A R T
;=========================================================================================
; 7. S T A R T
noClockStartup:
ClearRCwatchdog
noClockStartup:
ClearRCwatchdog
-;=========================================================================================
-; 7.8 Copy code from Flash to I-RAM
-;=========================================================================================
-#if I_RAM == ON
- LDI #_RAM_IRAM, R0
- LDI #_ROM_IRAM, R1
- LDI #sizeof(IRAM), R13
- CMP #0, R13
- BEQ copy_iram_end
-copy_iram1:
- ADD #-1, R13
- LDUB @(R13, R1), R12
- BNE:D copy_iram1
- STB R12, @(R13, R0)
-copy_iram_end:
- ClearRCwatchdog
-#endif
-
;=========================================================================================
; Standard C startup
;=========================================================================================
;=========================================================================================
; Standard C startup
;=========================================================================================
data_clr_end:
ClearRCwatchdog
data_clr_end:
ClearRCwatchdog
-;=========================================================================================
-; 7.11 Copy Init section from ROM to RAM
-;=========================================================================================
-; copy rom
-; All initialised data's (e.g. int i=1) must be stored in ROM/FLASH area.
-; (start value)
-; The Application must copy the Section (Init) into the RAM area.
- LDI #_RAM_INIT, R0
- LDI #_ROM_INIT, R1
- LDI #sizeof(INIT), R2
- CMP #0, R2
- BEQ:D copy_rom_end
- LDI #3, R12
- AND R2, R12
- BEQ:D copy_rom2
- MOV R2, R13
- MOV R2, R3
- SUB R12, R3
-copy_rom1:
- ADD #-1, R13
- LDUB @(R13, R1), R12
- CMP R3, R13
- BHI:D copy_rom1
- STB R12, @(R13, R0)
- CMP #0, R3
- BEQ:D copy_rom_end
-copy_rom2:
- ADD #-4, R13
- LD @(R13, R1), R12
- BGT:D copy_rom2
- ST R12, @(R13, R0)
-copy_rom_end:
- ClearRCwatchdog
-
start_main:
;=========================================================================================
; 7.14 call main routine
start_main:
;=========================================================================================
; 7.14 call main routine
-#pragma section CODE=IRAM,attr=CODE
-
void InitUart4(void)
{
// Initialize UART asynchronous mode
void InitUart4(void)
{
// Initialize UART asynchronous mode