Forum Discussion
Altera_Forum
Honored Contributor
21 years agoHow to porting u-boot to my own board?
Hello, everyone
I want to use u-boot on my board. I have two questions. 1. Before I use u-boot on my board, I just try to compile u-boot first. So, I follow the readme file. I use make PK1C20_config make all But there have errors. <div class='quotetop'>QUOTE </div> --- Quote Start --- In file included from /usr/include/sys/unistd.h:9, from /usr/include/unistd.h:6, from img2srec.c:61: /usr/include/sys/types.h:106: conflicting types for `int8_t' /usr/include/stdint.h:38: previous declaration of `int8_t' /usr/include/sys/types.h:108: warning: redefinition of `int16_t' /usr/include/stdint.h:39: warning: `int16_t' previously declared here /usr/include/sys/types.h:110: warning: redefinition of `int32_t' /usr/include/stdint.h:40: warning: `int32_t' previously declared here /usr/include/sys/types.h:112: warning: redefinition of `int64_t' /usr/include/stdint.h:45: warning: `int64_t' previously declared here make[1]: *** Error 1 make[1]: Leaving directory `/cygdrive/d/My_Project/MtxCyclone_uBoot/BootLoader/u-boot-1.1.3/tools make: *** [tools] Error 2[/b] --- Quote End --- I search the forum and find the answer given by smcnutt. <div class='quotetop'>QUOTE </div> --- Quote Start --- This looks like the sources directly from sourceforge.net ... this tree assumes you have an appropriately configured native gcc and shell environment -- which doesn't come with the nios2 toolchain 8-P The easiest thing to do is get the source tree from http://www.pysent.com/download (http://www.pysent.com/download) -- this tree has certain "nips & tucks" made to build cleanly with the default nios2 toolchain (under cygwin) -- and it's more up-to-date than the sourceforge tree (WRT Nios-II, the sourceforge tree has been lagging by several months).[/b] --- Quote End --- But I can not access the web link. Can give me the right link or the files? 2. If I want use u-boot on my MtxCyclone Board, how can I do? Just what should I do according to the PK1C20.h? Can give me more information or detailed steps than readme file? Thank you very much, LiangYi36 Replies
- Altera_Forum
Honored Contributor
Hi LiangYi,
> You said I can use flash.c. So, I browse flash.c(include /common/flash.c). I found AMDLV065D.c > just have both parts of two flash.c files. So, I think I can change AMDLV065D.c to my use. I was referring to the flash.c files found in most board-specific trees. Most of the supported boards (see the boards directory tree) contain a file named "flash.c" -- this is a common convention in u-boot. The boards that show support for the AM29DL323 are for example, RPXClassic, RPXlite_dw, and some of the esd boards (esd/common). Those trees will probably have the code you can use. > use NIOS_IDE Flash Programmer to download u-boot to my flash. After that I run ># nios2-terminal > Nothing happen, I do know why? You probably still have the flash programmer design loaded. Try reloading your application sof. > Communication port must be specified. > Use openport <port> to configure the communication port This is probably your problem ;-) Regards, --Scott - Altera_Forum
Honored Contributor
Hi Scott,
I have tested cfi_flash.c. I add<div class='quotetop'>QUOTE </div> --- Quote Start --- #define CFG_FLASH_CFI_DRIVER# define CFG_MAX_FLASH_SECT 71 /* Max# sects per bank */# define CFG_MAX_FLASH_BANKS 1 /* Max# of flash banks */# define CFG_FLASH_CFI[/b] --- Quote End --- to my board.h file. When I build u-boot, it has error in function flash_init(). <div class='quotetop'>QUOTE </div> --- Quote Start --- cfi_flash.c:343: undefined reference to 'monitor_flash_len'[/b] --- Quote End --- Is monitor_flash_len the u-boot image file size? What can I do about it? Furthermore, My flash is 16-bit width, should I define FLASH_CFI_16BIT in my board.h. Thanks, LiangYi - Altera_Forum
Honored Contributor
Hi LiangYi,
> cfi_flash.c:343: undefined reference to 'monitor_flash_len' Did you modify cfi_flash.c? My version has no reference to monitor_flash_len at line 343 -- it shows up in the statement at line 348. Just as a sanity check, your code should look like this:
Check your config macro definitions. This should not even be compiled, unless you are trying to run u-boot out of flash. > Furthermore, My flash is 16-bit width, should I define FLASH_CFI_16BIT in my board.h. No, it is defined in include/flash.c. The CFI code determines the width automatically. Regards, --Scott#if (CFG_MONITOR_BASE >= CFG_FLASH_BASE) && (CFG_MONITOR_BASE <= CFG_FLASH_BASE + CFG_FLASH_SIZE) flash_protect (FLAG_PROTECT_SET, CFG_MONITOR_BASE, CFG_MONITOR_BASE + monitor_flash_len - 1, flash_get_info(CFG_MONITOR_BASE));# endif - Altera_Forum
Honored Contributor
Hi Scott,
I have added cfi_flash.c to my u-boot, re-compiled u-boot and it can run in sdram. Then, I download the u-boot to my flash at 0x0 using Flash-Programmer. I reload the app sof file, open NIOS2-SDK Shell, run nios2-terminal. Nothing happen. I think that nios2-terminal start with jtag-uart, but not from uart. I do not know how to do next step? Give some info. Thank you. LiangYi - Altera_Forum
Honored Contributor
Hi LiangYi,
> I have added cfi_flash.c to my u-boot, re-compiled u-boot and it can run in sdram. Great! > I download the u-boot to my flash at 0x0 using Flash-Programmer How did you create the flash file? Typically, you should do the following: $ elf2flash --base=0x0 --end=0x7fffffff --input=u-boot --outfile=u-boot.flash --flash=<Uxx> $ nios2-flash-programmer --base=0x0 --input=u-boot.flash --sof=<xxx.sof> > Shell, run nios2-terminal. Nothing happen. > I think that nios2-terminal start with jtag-uart, but not from uart. When you run out of sdram, do you use the jtag uart ... and did you see the command prompt? If everything works with download/go to sdram, you most likely have a problem with the u-boot image stored in flash (either the flash file is incorrect ... or flash memory is not correct). Regards, --Scott - Altera_Forum
Honored Contributor
Hi Scott,
A strange problem, so annoyed. In Nios SDK Shell, I type command you say under my u-boot directory. $elf2flash --base=0x0 --end=0x1fffff --input=u-boot --output=u-boot.flash --flash=U20 Respond : elf2flash: No reset address provided on the command line, and none found in the ELF file Then, I add. $elf2flash --base=0x0 --end=0x1fffff --input=u-boot --output=u-boot.flash --flash=U20 --reset=0x0 Respond: elf2flash: Boot copier file name required, error generating Flash file, exiting I redo, add $elf2flash --base=0x0 --end=0x1fffff --input=u-boot --output=u-boot.flash --flash=U20 --reset=0x0 --boot=$SOPC_KIT_NIOS2/components/altera_nios2/boot_loader_cfi.srec Respond: elf2flash: read error: File not found: c:/altera/kits/nios2/component/altera_nios2/boot_loader_cfi.srec elf2flash: Error reading boot copier Does elf2flash need all parameters? My path C:\altera\kits\nios2\components\altera_nios2\boot_loader_cfi.srec is right, but elf2flash can not find the file. Why? LiangYi - Altera_Forum
Honored Contributor
Hi LiangYi,
> $elf2flash --base=0x0 --end=0x1fffff --input=u-boot --output=u-boot.flash --flash=U20 elf2flash is appropriate if you boot from an epcs, ... sorry for misleading you. When you are using parallel flash with u-boot, bin2flash is what you want (since the u-boot make will generate a binary image). E.g.: $ bin2flash --base=0x0 --location=0x0 --flash=U20 --input=u-boot.bin --output=u-boot.flash > $elf2flash --base=0x0 --end=0x1fffff --input=u-boot --output=u-boot.flash --flash=U20 --reset=0x0 > --boot=$SOPC_KIT_NIOS2/components/altera_nios2/boot_loader_cfi.srec u-boot does not require the boot copier ... it will relocate itself to its run-time address. Regards, --Scott - Altera_Forum
Honored Contributor
Hi Scott,
It make me headache. My Flash progrmmer (Microtronix official Providing) can not work under Nios SDK Shell. But it works fine in Nios IDE. I re-generate my flash-programmer design, but the same. The infomation under Nios SDK Shell is (I copy .sof to u-boot directory) <div class='quotetop'>QUOTE </div> --- Quote Start --- > $ nios2-flash-programmer --base=0x0 --input=u-boot.flash --sof=mtx_nios_dev_board_cyclone_1c20.sof nios2-flash-programmer: Launching Quartus Programmer to download: mtx_nios_dev_board_cyclone_1c20.sof (here download to my FPGA) Send <64> failed. Unable to synchronize with target. ......nios2-flash-programmer: Error opening target hardware[/b] --- Quote End --- OR <div class='quotetop'>QUOTE </div> --- Quote Start --- ......nios2-flash-programmer: Error opening target hardware ......nios2-flash-programmer: Unable to open flash device after successfully communicating with target.[/b] --- Quote End --- Is there any difference between nios2-flash-programmer in Nios SDK Shell and Flash Programming in Nios IDE? LiangYi - Altera_Forum
Honored Contributor
> Is there any difference between nios2-flash-programmer in Nios SDK Shell and Flash
> Programming in Nios IDE? It is the same application ... but the parameters may be different. --Scott - Altera_Forum
Honored Contributor
Hi Scott,
<div class='quotetop'>QUOTE </div> --- Quote Start --- > $ nios2-flash-programmer --base=0x0 --input=u-boot.flash --sof=mtx_nios_dev_board_cyclone_1c20.sof nios2-flash-programmer: Launching Quartus Programmer to download: mtx_nios_dev_board_cyclone_1c20.sof (here download to my FPGA) Send <64> failed. Unable to synchronize with target. nios2-flash-programmer: Error opening target hardware[/b] --- Quote End --- This is the error infomation displayed in Nios SDK Shell. But It runs OK in Nios IDE. I do not know what is wrong. Have you ever seen this problem? I will try again. Thanks, LiangYi