2010-06-28 09:16:17     I can't transfer kernel from RAM to FLASH

Document created by Aaronwu Employee on Sep 25, 2013
Version 1Show Document
  • View in full screen mode

2010-06-28 09:16:17     I can't transfer kernel from RAM to FLASH

Lorenzo Mariani (ITALY)

Message: 90682   

 

Hi everyone!

 

I have an issue with my paged flash, here is my configuration:

 

        Custom board with bf536 rev 0.3

 

        u-boot-2008.10-2009R1.1-rc1

 

        uClinux-dist-2009R1.1-RC4 on RAM ( I want to put in on Flash)

 

        Intel 8MB(64 Mbit ) paged flash (parallel NOR Flash) – model PC28F640J3d-75

 

 

 

I followed the configuration on http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:mtd, here is my customization:

 

 

 

#if defined(CONFIG_MTD_GPIO_ADDR) || defined(CONFIG_MTD_GPIO_ADDR_MODULE)

 

static struct mtd_partition stamp_partitions[] = {

 

{

 

.name = "bootloader(nor)",

 

.size = 0x60000,

 

.offset = 0,

 

}, {

 

.name = "linux kernel(nor)",

 

.size = 0x500000,

 

.offset = MTDPART_OFS_APPEND,

 

},{

 

.name = "file system(nor)",

 

.size = 0x280000,

 

.offset = MTDPART_OFS_APPEND,

 

},{

 

.name = "MAC Address(nor)",

 

.size = MTDPART_SIZ_FULL,

 

.offset = MTDPART_OFS_APPEND,

 

.mask_flags = MTD_WRITEABLE,

 

}

 

};

 

 

 

The Flash is subdivided in 8 pages of 1MB each, and to access to one page I have to write the number of the page in the page select. I have modified jtag bfloader (bfloader/boards/generic/main.c ), u-boot (u-boot/drivers/mtd/cfi_flash.c), and kernel (linux-2.6.x/drivers/mtd/maps/gpio-addr-flash.c) to work with the page select (the changes are attached) , and I think there are right.

 

 

 

I can access to all the Flash memory using a page select chip, but when I try to move the kernel from RAM to FLASH using this procedure:

 

 

 

        tftp 0x03000000 uImage

 

        protect off 0x20060000 0x2055FFFF

 

        erase 0x20060000 0x2055FFFF

 

        cp.b 0x03000000 0x20060000 0x500000

 

        

 

the kernel isn't copied to Flash.

 

 

 

I hope you can help me.

 

Thanks in advance for any answer!

 

Regards

 

changes in u-boot.c

changes in bfloader.c

changes in kernel.c

TranslateQuoteReplyEditDelete

 

 

2010-06-28 12:48:30     Re: I can't transfer kernel from RAM to FLASH

Mike Frysinger (UNITED STATES)

Message: 90696   

 

changing common code is not supported.  please read look at the cm-bf537 board port for how to do it correctly in u-boot and the kernel.

 

as for "bfloader", i have no idea what that it is, but it isnt from us, so there is no support for that here.

QuoteReplyEditDelete

 

 

2010-06-30 03:42:14     Re: I can't transfer kernel from RAM to FLASH

Lorenzo Mariani (ITALY)

Message: 90767   

 

Thanks Mike for the answer!

 

I'm sorry, I made a mistake, "bfloader" is the software of the jtag loader made from section5 ( http://www.section5.ch/blackfin )

 

I did not understand where I have to look to do the right changes, can you give me a link, please?

 

Thanks again

 

Regards.

TranslateQuoteReplyEditDelete

 

 

2010-06-30 14:20:23     Re: I can't transfer kernel from RAM to FLASH

Mike Frysinger (UNITED STATES)

Message: 90777   

 

there is no documentation on it atm.  look at the board/cm-bf537e/gpio_cfi_flash.c file and use the CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS board setting.

QuoteReplyEditDelete

 

 

2010-07-01 07:31:40     Re: I can't transfer kernel from RAM to FLASH

Lorenzo Mariani (ITALY)

Message: 90804   

 

Thanks again for the advice Mike!

 

I have had to upgrade the u-boot  to the  u-boot-2010.03 version to follow your hint.

 

I think you gave me a very useful hint,  but when I use the CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS board setting and i call "gpio_cfi_flash_init" in the end of  "misc_init_r" (these are the changes like in the board/cm-bf537e/gpio_cfi_flash.c file) , I can't anymore use the Ethernet  (maybe is there problem with the MAC address saved on the last sector of the Flash? )

 

I paste here the files that I modified following board/cm-bf537e/gpio_cfi_flash.c

 

Thanks again.

 

Regards.

 

bf537-stamp.h

gpio_cfi_flash.c

bf537-stamp.c

TranslateQuoteReplyEditDelete

 

 

2010-07-02 11:28:13     Re: I can't transfer kernel from RAM to FLASH

Mike Frysinger (UNITED STATES)

Message: 90839   

 

you deleted all the important logic from the gpio_cfi_flash code

 

why are you modifying bf537-stamp files if you arent using a bf537-stamp ?

QuoteReplyEditDelete

 

 

2010-07-02 11:45:27     Re: I can't transfer kernel from RAM to FLASH

Lorenzo Mariani (ITALY)

Message: 90840   

 

I made some improvements, but it doesn't work yet as expected.

 

In latest svn version I could not make ethernet work, so I backported the gpio_cfi_flash.c modifications to the 2008.10-2009R1.1-rc1 version.

 

I am encountering a strange behaviour: when flash is destination everything works correctly (erase and write are ok - tested with a separete dump from jtag) and the page selection procedure get called.

 

Source file is gpio_cfi_flash.c previously posted.

 

bfin> cp.b 0x03000000 0x20500000 0x10

Copy to Flash... ==> addr: 20500000 ==> page: 5

Flash not Erased

 

 

 

When flash is the source the page selection procedure does not get called and the processor stalls on memory access exceptions.

 

bfin> cp.b 0x20500000 0x03000000 0x10

 

Ack! Something bad happened to the Blackfin!

 

SEQUENCER STATUS:

SEQSTAT: 0000c026  IPEND: 8030  SYSCFG: 0032

  HWERRCAUSE: 0x3: external memory addressing error

  EXCAUSE   : 0x26: dcplb miss

  physical IVG15 asserted : <0x03f8054c> { _evt_default + 0x0 }

RETE: <0x81432047> { ___smulsi3_highpart + 0x7d49a08b }

RETN: <0x03f1f220> /* unknown address */

RETX: <0x03f8a11a> { _do_mem_cp + 0x192 }

RETS: <0x03f8a084> { _do_mem_cp + 0xfc }

RETI: <0x03f8a11a> { _do_mem_cp + 0x192 }

DCPLB_FAULT_ADDR: <0x20500000> { ___smulsi3_highpart + 0x1c568044 }

ICPLB_FAULT_ADDR: <0x03f8a11a> { _do_mem_cp + 0x192 }

 

 

Please note that I am getting the same behaviour with the latest SVN version.

 

Is there anybody who knows how to trigger the platform specific flash_read##size function?

 

I'll conduct some more tests and let you know.

 

Many thanks for the support you provided.

 

Best regards.

 

Lorenzo

TranslateQuoteReplyEditDelete

 

 

2010-07-05 03:36:40     Re: I can't transfer kernel from RAM to FLASH

Lorenzo Mariani (ITALY)

Message: 90900   

 

you deleted all the important logic from the gpio_cfi_flash code

 

why are you modifying bf537-stamp files if you arent using a bf537-stamp ?

 

---

 

I deleted only the instructions that work with GPIO_PIN, and I don't use them to access the Flash memory.

 

I'm modifying them because my board (custom bf536 board)  is very similar to it

 

Thanks.

 

Regards

TranslateQuoteReplyEditDelete

 

 

2010-07-05 03:52:39     Re: I can't transfer kernel from RAM to FLASH

Mike Frysinger (UNITED STATES)

Message: 90901   

 

the way you're using the GPIOs is not the way the GPIO flash code intended.  you should not modify the kernel gpio-addr-flash.c but instead write your own mapping driver.  you should also rename the u-boot gpio_cfi_flash to avoid confusion with the real GPIO assisted addressing driver.

 

as for the board porting, you really should be creating your own and not hacking apart existing ones.  it is trivial to create your own.

QuoteReplyEditDelete

 

 

2010-07-05 03:53:24     Re: I can't transfer kernel from RAM to FLASH

Mike Frysinger (UNITED STATES)

Message: 90902   

 

what exactly do you mean by "cant use ethernet anymore" ?  show some actual u-boot commands & output to illustrate your problem.

QuoteReplyEditDelete

 

 

2010-07-05 05:26:19     Re: I can't transfer kernel from RAM to FLASH

Lorenzo Mariani (ITALY)

Message: 90903   

 

what exactly do you mean by "cant use ethernet anymore" ?  show some actual u-boot commands & output to illustrate your problem.

 

---

 

using the u-boot 2010.03 I can't even ping my pc, but now I'm using  u-boot-2010R1_ALPHA1 and it the ethernet works (I can ping, and I can transfer the uImage on RAM using tftp) but the problem is still the difference of behaviour when flash is the destination of a command and when it is the source, like I wrote above.

TranslateQuoteReplyEditDelete

 

 

2010-07-05 05:38:11     Re: I can't transfer kernel from RAM to FLASH

Mike Frysinger (UNITED STATES)

Message: 90904   

 

the crash when using 'cp' is expected behavior.  the read functions do not do any sort of address translation.  you will need to write a custom function that allows you to select a page before reading from the actual address.

QuoteReplyEditDelete

 

 

2010-07-05 05:46:23     Re: I can't transfer kernel from RAM to FLASH

Lorenzo Mariani (ITALY)

Message: 90906   

 

this is the output of a ping to my pc in u-boot-2010.03:

 

bfin> ping 192.168.200.64

Eth_halt: ......

Trying bfin_mac

Eth_init: ......

Using bfin_mac device

sending ARP for 40c8a8c0

ARP broadcast 1

BFIN EMAC send: length = 42

bfin_EMAC_recv: len = 60

packet received

packet received

Receive from protocol 0x806

Got ARP

ARP broadcast 2

BFIN EMAC send: length = 42

Eth_halt: ......

ping failed; host 192.168.200.64 is not alive

 

 

while this is the output of a ping to my pc in u-boot-2010R1_ALPHA1:

 

bfin> ping 192.168.200.64

Eth_halt: ......

Trying bfin_mac

Eth_init: ......

Using bfin_mac device

sending ARP for 40c8a8c0

ARP broadcast 1

BFIN EMAC send: length = 42

bfin_EMAC_recv: len = 60

packet received

packet received

Receive from protocol 0x806

Got ARP

Got ARP REPLY, set server/gtwy eth addr (00:24:21:a4:29:b0)

Got it

BFIN EMAC send: length = 42

bfin_EMAC_recv: len = 60

packet received

packet received

Receive from protocol 0x800

Got IP

len=28, v=45

Eth_halt: ......

host 192.168.200.64 is alive

TranslateQuoteReplyEditDelete

 

 

2010-07-05 05:51:17     Re: I can't transfer kernel from RAM to FLASH

Mike Frysinger (UNITED STATES)

Message: 90907   

 

that version information is not useful.  the 2010R1 alpha1 tag is using 2010.03.

 

not that it matters if an older version of svn trunk doesnt work while a new version does ... we dont support arbitrary svn revs.

QuoteReplyEditDelete

 

 

2010-07-05 06:05:27     Re: I can't transfer kernel from RAM to FLASH

Lorenzo Mariani (ITALY)

Message: 90908   

 

the crash when using 'cp' is expected behavior.  the read functions do not do any sort of address translation.  you will need to write a custom function that allows you to select a page before reading from the actual address.

 

---

 

Why hasn't  the address translation been done in the read functions?  As I can read in the code

 

#define MAKE_FLASH(size, sfx) \

void flash_write##size(u##size value, void *addr) \

{ \

    __raw_write##sfx(value, gpio_cfi_flash_swizzle(addr)); \

} \

u##size flash_read##size(void *addr) \

{ \

    return __raw_read##sfx(gpio_cfi_flash_swizzle(addr)); \

}

 

both flash_read and flash_write use the page selection that i put in gpio_cfi_flash_swizzle function, doesn't 'cp' call flash_read  when it has a flash address as a source parameter?

 

How can I specify the flash address space just as I did with the kernel?

TranslateQuoteReplyEditDelete

 

 

2010-07-05 06:23:55     Re: I can't transfer kernel from RAM to FLASH

Mike Frysinger (UNITED STATES)

Message: 90909   

 

flash_read is not used when doing things like 'cp' or 'md' -- this is by u-boot design and not a bug.  there is no support currently for what you want to do beyond what i already described -- manually flip pages and read by hand.

QuoteReplyEditDelete

 

 

2010-07-05 07:32:09     Re: I can't transfer kernel from RAM to FLASH

Lorenzo Mariani (ITALY)

Message: 90910   

 

flash_read is not used when doing things like 'cp' or 'md' -- this is by u-boot design and not a bug.  there is no support currently for what you want to do beyond what i already described -- manually flip pages and read by hand.

 

---

 

I found a u-boot command good for me: 'flread' . Now the kernel is saved in flash and every time that I turn on the board, the kernel is copied in RAM and booted. This is a good solution for me.  Many Thanks for all your help

 

Best Regards

 

Lorenzo

Outcomes