OpenWrt Forum Archive

Topic: U-Boot mod for routers with AR9331/AR9344

The content of this topic has been archived between 3 Apr 2015 and 7 May 2018. Unfortunately there are posts – most likely complete pages – missing.

pepe2k wrote:
Sharonbuss wrote:

I think the parameter for DDR1 memory has some different, 
I want to modify the driver strength and ddr frequency,
could you where to make modifications?

u-boot/cpu/mips/ar7240/meminit.c -> function wasp_ddr_initial_config
Don't ask me about registers values and definitions - I don't have access to AR9341 data sheet...

Thanks a lot!
I have found some info in Ar7240_soc.h.

hackru wrote:

How did you forced DDR1 in config?

In Meminit.c

#    switch(WASP_RAM_TYPE(ar7240_reg_rd(WASP_BOOTSTRAP_REG))){
        switch (3){

(Last edited by Sharonbuss on 25 Mar 2014, 04:45)

Hello,

My question probabbly will be silly for some of you, but after some reading I did not find a clear way to install pepe2k uboot mod using MTD command.

I try to do it on TP-LINK 740N version 4, searial port is hard to connect on it. Need to soldier parts on board and that is not for my hands.

Or: Use DDWRT, to flash Ubootmod. From web 192.168.1.1 set password and in Services check SSHd and SSH TCP Forwarding. Run telnet 192.168.1.1 and do uboot backup with the command:

cat /dev/mtd0 > /tmp/uboot_backup.bin

Then download uboot_backup.bin from the /tmp directory with WinSCP using SCP protocol. Uboot_backup.bin file is 128KB and open it with HEX editor (TinyHexer) and the part from 0x00 to 0x010000 replace with the contents (64KB) of ubootmod for wr740n v4. Save the file as ubootmod.bin. Upload ubootmod.bin with WinSCP to /tmp and flash it with telnet or Putty SSH:

mtd -r write /tmp/ubootmod.bin RedBoot

Good Luck

(Last edited by vladizlat on 31 Mar 2014, 22:07)

Thanks for the quick reply, I think I will manage to do that.
I got another question.
As I understand, u-boot is responsible for gpio (router leds) initialization. Is it possible not to flash router leds during boot process. I want to connect relay box on leds, but if they blink on reboot it will be a problem.

nedoskiv wrote:

As I understand, u-boot is responsible for gpio (router leds) initialization.

Yes, in most case I use some GPIOs for LEDs.

nedoskiv wrote:

Is it possible not to flash router leds during boot process. I want to connect relay box on leds, but if they blink on reboot it will be a problem.

Yes, but it will require changes in code and own compilation. Take a look here:
https://github.com/pepe2k/u-boot_mod/bl … ard.c#L462

I have some plans to make low level GPIO initialization which can be changed in U-Boot command line (like O/C profiles for AR9331) and stored in FLASH, but... at this time I'm very busy with other projects.

(Last edited by pepe2k on 1 Apr 2014, 12:07)

I report successful modifying the code (commented the line for all_led_on) and installing pepe2k u-boot using DD-WRT.
DD-WRT is not really finished for tp-link 740N version 4, but do the job, now will try to modify openwrt sources.

Thank you all for the help and fast responses.

(Last edited by nedoskiv on 1 Apr 2014, 20:07)

Hello. I hope this is the right place to post this, if not I apologize.

I have a couple of wr703n devices flashed with OpenWrt that were used for a special network appliance.  One of them the USB host can power the device. On the other one only the micro-USB can power the device.  We need to be able to power the device with regular USB port, not mico USB. Is there a way to enable that.

Thanks.
Rez

I tried to compile this u-boot for my TP-Link WDR3600, however i am not very good at this and its telling me the config is not present. Any chance you could compile it for me?  I also need the TP-Link WDR3500 as well. Thanks!

hello again. Next question coming...

My goal is now to make web mode require a password. So far i manage to locate where are html files (u-boot/net/uip-0.9/fsdata.c), but do not have same success with the part of the code that handle them.

jeffjj wrote:

I tried to compile this u-boot for my TP-Link WDR3600, however i am not very good at this and its telling me the config is not present. Any chance you could compile it for me?  I also need the TP-Link WDR3500 as well. Thanks!

I'm busy... sorry.

nedoskiv wrote:

My goal is now to make web mode require a password. So far i manage to locate where are html files (u-boot/net/uip-0.9/fsdata.c), but do not have same success with the part of the code that handle them.

fsdata.c file is generated from files in vendors subfolders:
https://github.com/pepe2k/u-boot_mod/tr … pd/vendors

Server source:
https://github.com/pepe2k/u-boot_mod/bl … pd/httpd.c

Hmm... Look like my copy of the sources do not contain such folder and files. That is the reson I did not notice httpd folder.
Perhaps I downloaded some old version.


P.S. I downloaded new version and directory tree is as described in pepe2k post. Add openwrt toolchain and just run make command to check is it working. It works with one important warrning:

Image Name:   u-boot image
Created:      Tue Apr  8 09:03:00 2014
Image Type:   MIPS Linux Firmware (lzma compressed)
Data Size:    49952 Bytes = 48.78 kB = 0.05 MB
Load Address: 0x80010000
Entry Point:  0x80010000
make[1]: Entering directory `/openwrt/pepe2k-uboot-7.4.2014'

======= Preparing 64KB file filled with 0xFF... =======
64+0 records in
128+0 records out
65536 bytes (66 kB) copied, 0,00286629 s, 22,9 MB/s

======= Copying U-Boot image... =======
128+1 records in
128+1 records out
65680 bytes (66 kB) copied, 0,000918969 s, 71,5 MB/s

======= U-Boot image ready, size: 65680 bytes =======



     **********************************
     *   U-BOOT IMAGE SIZE TOO BIG!   *
     **********************************

I guess oversize is a  problem? Here is old code that work without this problem:


Image Name:   u-boot image
Created:      Tue Apr  8 10:42:00 2014
Image Type:   MIPS Linux Firmware (lzma compressed)
Data Size:    43075 Bytes = 42.07 kB = 0.04 MB
Load Address: 0x80010000
Entry Point:  0x80010000
make[1]: Entering directory `/openwrt/pepe-uboot/u-boot_sources_for_tp-link_AR9331_by_pepe2k'
\n======= Preparing 64 KB file filled with 0xFF... =======
64+0 records in
128+0 records out
65536 bytes (66 kB) copied, 0,00447146 s, 14,7 MB/s
\n======= Copying U-Boot image... =======
112+1 records in
112+1 records out
57647 bytes (58 kB) copied, 0,000844541 s, 68,3 MB/s
\n======= U-Boot image ready, size: 65536 bytes =======

(Last edited by nedoskiv on 8 Apr 2014, 09:55)

This mod really helps me with my project a lot! Especially the dhcp-functionality is important for my project. I am building a custom U-BOOT for a TL-WR740n v4 which is supposed to configure the network over dhcp, download a ramfs-image and then boot that.

But I have one problem: When booting, I get:

Hit any key to stop autobooting:  0 

Link down: eth0
Link down: eth1
Booting image at: 0x80800000

   Image name:    
   Image type:   MIPS Linux Kernel Image (lzma compressed)
   Data size:    0 Bytes = 0 kB
   Load address: 0x20028124
   Entry point:  0x00000F22

Uncompressing kernel image... ## Error: LZMA error num: 1

## Error: failed to execute 'bootcmd'!

My bootcmd is "dhcp; bootm"
If I run boot from inside the uBOOT-console, the bootcmd works perfectly and the system loads and boots the remote image.

But when the bootcmd is invoked from auto-booting, the dhcp-command does not execute and thus nothing is present at the boot adress. Do you, pepe2k, or anybody else know what causes this issue and how I might solve it?

Unrelated: How can I exclude the Website stuff from the build? I do not need it and would prefer the bootloader to reset when booting the supposed image fails. (This way, the device would stay in a loop if the tftp host is down and nobody would have to go to the device and reset it!)

locutus wrote:

My bootcmd is "dhcp; bootm"

Try add proper address for bootm command.

locutus wrote:

Unrelated: How can I exclude the Website stuff from the build? I do not need it and would prefer the bootloader to reset when booting the supposed image fails. (This way, the device would stay in a loop if the tftp host is down and nobody would have to go to the device and reset it!)

You will need a lot of code change for that.
Take a look here: https://github.com/pepe2k/u-boot_mod/bl … ain.c#L242 and just change "NetLoopHttpd()" call.

pepe2k wrote:
locutus wrote:

My bootcmd is "dhcp; bootm"

Try add proper address for bootm command.

I tried different command pairings. none work.

But after some evaluation, I noticed that the eth-devices always are down during boot. So I changed the bootdelay from 1 to 4 and also added a delay of 850ms right before execution of the bootcmd in the main.c. And all of a sudden, everything works as it should!


pepe2k wrote:
locutus wrote:

Unrelated: How can I exclude the Website stuff from the build? I do not need it and would prefer the bootloader to reset when booting the supposed image fails. (This way, the device would stay in a loop if the tftp host is down and nobody would have to go to the device and reset it!)

You will need a lot of code change for that.
Take a look here: https://github.com/pepe2k/u-boot_mod/bl … ain.c#L242 and just change "NetLoopHttpd()" call.

Thanks for showing me the location. I just replaced the NetLoopHttpd() with do_reset() and included the include/exports.h. This way, the router reboots every time the system fails.

locutus wrote:

But after some evaluation, I noticed that the eth-devices always are down during boot. So I changed the bootdelay from 1 to 4 and also added a delay of 850ms right before execution of the bootcmd in the main.c. And all of a sudden, everything works as it should!

Good point, I will add also "sleep" command in future.

BTW, new version has Hush shell included, so you can use more complex scripts, take a look at this commit:
https://github.com/pepe2k/u-boot_mod/co … befb988afb

I'm trying to make u-boot for AP94 target
I get source from wr703n-uboot-with-web-failsafe project
I can compile u-boot.bin successfully, however after flashing to my router,
networking not work, neither in u-boot or in root
Anybody knows what could be wrong?

Thanks you do it. I download your code and compile it. I use external FLASH programmer to download it. But there is a problem.The WiFi does not work.I don't know how to solve the problem. Will you help me out?
Here is the U-boot blog.
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
AP121 (AR9331) U-Boot for TL-WR703N

DRAM:   64 MB DDR 16-bit
FLASH:  Winbond W25Q128 (16 MB)
CLOCKS: 400/400/200/33 MHz (CPU/RAM/AHB/SPI)

## Error: MAC is invalid, using fixed!

LED on during eth initialization...

## Error: MAC address in FLASH is invalid, using fixed!
## Error: MAC address in FLASH is invalid, using fixed!
Press reset button for at least:
- 3 sec. to run web failsafe mode
- 5 sec. to run U-Boot console
- 7 sec. to run U-Boot netconsole

Reset button is pressed for:  5

Button was pressed for 5 sec...
Starting U-Boot console...

uboot>
//////////////////////////////////////////////////////////////////////////////////

And when the Openwrt start up,  the ath9k unable to initialize.
///////////////////////////////////////////////////////////////////////////////////
[    9.220000] ath: phy0: Unable to initialize hardware; initialization status: -5
[    9.230000] ath9k ar933x_wmac: failed to initialize device
[    9.230000] ath9k: probe of ar933x_wmac failed with error -5

(Last edited by lianbinzhang on 12 Apr 2014, 09:01)

dony71 wrote:

[...]however after flashing to my router, networking not work, neither in u-boot or in root[...]

You need to add a proper network driver in U-Boot.
Network is initialized in U-boot, not again/later in OpenWrt.

lianbinzhang wrote:

[...]## Error: MAC is invalid, using fixed![...]

Missing second 64 KB block from original FLASH.

lianbinzhang wrote:

[...][    9.230000] ath9k: probe of ar933x_wmac failed with error -5[...]

Missing ART partition (last 64 KB block from original FLASH).

pepe2k wrote:

[...]## Error: MAC is invalid, using fixed!
Missing second 64 KB block from original FLASH.[...]

[...][    9.230000] ath9k: probe of ar933x_wmac failed with error -5[...]
Missing ART partition (last 64 KB block from original FLASH).

And what should I do to solve this problem?

(Last edited by lianbinzhang on 12 Apr 2014, 09:36)

lianbinzhang wrote:
pepe2k wrote:

[...]## Error: MAC is invalid, using fixed!
Missing second 64 KB block from original FLASH.[...]

[...][    9.230000] ath9k: probe of ar933x_wmac failed with error -5[...]
Missing ART partition (last 64 KB block from original FLASH).

And what should I do to solve this problem?

Did you erase whole FLASH before writing there my U-Boot?

pepe2k wrote:
lianbinzhang wrote:
pepe2k wrote:

[...]## Error: MAC is invalid, using fixed!
Missing second 64 KB block from original FLASH.[...]

[...][    9.230000] ath9k: probe of ar933x_wmac failed with error -5[...]
Missing ART partition (last 64 KB block from original FLASH).

And what should I do to solve this problem?

Did you erase whole FLASH before writing there my U-Boot?

Yes, I did.

pepe2k wrote:
dony71 wrote:

[...]however after flashing to my router, networking not work, neither in u-boot or in root[...]

You need to add a proper network driver in U-Boot.
Network is initialized in U-boot, not again/later in OpenWrt.

pepe2k,
wrt400n is based on AR8236 switch
i thought driver already defined in include/configs/ap94.h
................
#define CFG_ATHRS26_PHY                         1
#define CFG_AG7100_NMACS                        2
................
Am I understanding wrongly?

(Last edited by dony71 on 12 Apr 2014, 10:51)

pepe2k wrote:
lianbinzhang wrote:

Did you erase whole FLASH before writing there my U-Boot?

Yes, I did.

Do you have a backup of the original FLASH? You need to write back the ART-Partition and the UBoot general config partition to your device.

If you don't have a backup, you will need to get the correct files for your router from someone who has the same model as you do. But: The UBoot general config will contain a different mac adress (with a hex editor and the knowledge of the mac adress stored in the replacement, you can change it to the mac adress the router should have, though!). Regarding the ART-backup, as mentioned in the article linked above, your WLAN will most likely not perform as well as before.


What programmer did you use to program? flashrom? You can tell flashrom to only write specific parts of the flash by using a rom layout file (see the manpage for flashrom) - this should similary work for other flash programmers, too!
Also, it is generally a good idea to first download the whole flash as a backup and then use tools like dd to actually overwrite parts of "!a copy of the backup!" with the new data. This way, the image you will be flashing will always contain all the old stuff so if the programmer screws up, you still do not loose your data!