Open DanielRIOT opened 6 years ago
Hi @DanielRIOT , choosing 250000bps as baud rate was an unfortunate decision at the time but we have to live with that; there's a ugly patch that needs to be backported every time that enables that baudrate (https://github.com/arduino/lede-yun/blob/master/target/linux/ar71xx/patches-4.9/821-serial-core-add-support-for-boot-console-with-arbitr.patch) . The reconfiguration to 9600 happens because bootargs request 250000 but fails (without that patch) and falls back to the minimum supported speed (9600). I'd love to be able at some point to adopt mainline openwrt, so any advice or code could really help in this!
Hi @facchinm
that makes sense,
a workaround I had is :
serial-reset /dev/ttyATH0
inrc.local
so it comes up later.
Thank you for pointing me to the patch, I updated it and did a test compile on 18.06 ( this repo ) and it seems to build happily- will test it when i get to a Yun tomorrow...
I also added these feeds to my feeds.conf so I can pull in yun-scripts[] and yun-config[] and yun-bridge[m].
src-git arduino https://github.com/arduino/openwrt-arduino-packages.git;for-lede-next
after that one can follow the "regular" openwrt build process and all seems well ( I have gotten some "invalid image type" messages when doing sysupgrade, and will hunt those down soon too.
I'm using the uBoot from your Go-updater for all of these and it works without issue.
I also found we can set the kernel serial port to 115200, and then only u-boot needs to be set to match
find Yun in /target/linux/ar71xx/image/generic.mk and set CONSOLE := ttyATH0,115200
115200 will probably break the yun-bridge as it expects the higher baudrate between the AVR and the AR9331
The updated patch for the new kernel is here... 821-serial-core-add-support-for-boot-console-with-arbitr.zip
I tested the ported patch on my Yun and it seems to work as expected ( baudrate at 250000 )
I've also tested loading sketches to the AVR via the network upload and it runs fine, I haven't added the JuCI "desktop" interface yet as I prefer the Openwrt configuration panel for my current project.
Could someone upload an 18.06.x image for the Yun? Or will there be an official one?
hi @satmandu , you can get a pre-built image from openWRT/LEDE here : https://downloads.openwrt.org/releases/18.06.1/targets/ar71xx/generic/openwrt-18.06.1-ar71xx-generic-arduino-yun-squashfs-sysupgrade.bin
it doesn't have the baudrate patch applied, so it might be better to build your image from source using the openWRT build tools so you can apply the patch - at least until the patch is integrated into their current release
@DanielRIOT Any chance you'd be willing to put up a diff to the 18.06.x tree on github showing the changes you had to get a minimal working build for the yun?
The 18.06.1 release sysupgrade file is missing enough yun specific stuff (such as required kernel patches to get avrdude to work) to not connect easily to the arduino side.
@satmandu will try and put up a repo later this week - You'll have to build it yourself to get the yun specific stuff in there ( fixed baudrate, AVRdude, Yun conf and Yun scripts)
Thanks. The Yun specific stuff in the tree aside from JUCi and the Arduino frontend area really all that I am looking for.
@satmandu ,
I cloned the master repo from openwrt ( https://github.com/openwrt/openwrt/tree/master ) and set up my build as this instructs )
Then added the arduino packages to feeds.conf.default ( https://github.com/arduino/openwrt-arduino-packages ) ( you can use this as an example )
called ./scripts/feeds update -a
and ./scripts/feeds install -a
to get them into my "packages" directory and so they show up in menuconfig.
also needed to add the serial baudrate patch to the new kernel ( 4.14 ) in/target/linux/ar71xx/patches-4.14
951-MIPS-serial-core-add-support-for-arb-baudrates.zip if you don't do this the Yun will have a console at 9600 baudrate and bridge will also not work as expected at al times. - you can update the yunserial Arduino sketch to have 9600 as an option :D )
run make menuconfig
In menuconfig select the target systemAtheros ar7xxx/ar9xxx
, Subtarget : Generic
, target profile as Arduino Yun
select yun-scripts
and yun-conf
and luci-app-arduino-webpanel
and any other things you think might be useful
You might have to update u-boot ( using the go-updater - it works really well ), and then load your new image with ssh ( scp runs if you have ssh open, so you can use winSCP in windows or the regular linux scp to copy it to /tmp)
sysupgrade -v -F /tmp/openwrt-ar71xx-generic-arduino-yun.bin
from terminal ( for some reason the magic number and "board name" doesn't get included or is calculated wrong and then the regular sysupgrade and web upgrade do not accept the new image and thus you need the Force -F
flagyou might need to see compare which packages to include in your build to get the same behavior as Arduino's Yun build ( I haven't focused on recreating the Yun build completely - Yun is a convenient ar71xx platform for me to experiment on with OpenWrt specific stuff
all of this might brick your Yun during any stage (happened to me lots of times and its recoverable as long as you don't wipe out u-boot or ART partition on the flash, but you can always use something like Flashrom , or a arduino due/zero / any 3v3 device to read out or reprogram the flash on the Yun to put u-boot and ART back assuming you backed it up beforehand - you can do that from terminal - check out this wiki )
The "Sysupgrade" image that is built by the regular build can be uploaded to the flash from u-boot via tftp directly to the boot memory location ( 0x9f050000 ) - check the u-boot bootargs to get the correct location - it also has a lot of other things set up in there that give a useful insight into the system as it differs from the "regular" ar71xx targets
also keep mindful that there are some bugs in the newer kernel that may pop up as lots of things have changed ( i get occasional restarts when I change wifi channel on the ar71xx platforms )
I built this image : [Uploading openwrt-ar71xx-generic-arduino-yun-squashfs-sysupgrade.zip…]()
Thanks. That parallels much of what I was doing. It is reassuring to hear that you did much of the same, and yes I noted that annoyance with having to run sysupgrade -v -F
too.
Now that 18.06.2 is rolling out I'm tempted to just use https://github.com/openwrt/openwrt/tree/openwrt-18.06 as a base repo to work off of.
@DanielRIOT You mean ./scripts/feeds install -a
not ./scripts/feeds/install -a
.
@DanielRIOT Did you ever run into this error?
* check_data_file_clashes: Package yunbridge wants to install file openwrt/build_dir/target-mips_24kc_musl/root-ar71xx/usr/bin/pretty-wifi-info.lua
But that file is already provided by package * yun-scripts
* opkg_install_cmd: Cannot install package yunbridge.
Hi @satmandu , i did and then removed yunbridge from the build ( I don't use it at all - i use SPI to speak to the ATmega ),
( we might need to relook at the Arduino packages and sort out the dependencies and installations so these clashes don't happen )
Thanks. That parallels much of what I was doing. It is reassuring to hear that you did much of the same, and yes I noted that annoyance with having to run
sysupgrade -v -F
too.Now that 18.06.2 is rolling out I'm tempted to just use https://github.com/openwrt/openwrt/tree/openwrt-18.06 as a base repo to work off of.
I've also been looking into porting it o the ATH79 branch ( there are discussions on porting ar71xx platforms to ATH79 and devicetree so its more compatible with upstream linux developments to rely on devicetree descriptions rather than a multitude of platform and board specific code snippets and files - to add or maintain a new board it takes about 4-5 file entries in /target/linux/ar71xx, with ATH79 should only be the devicetree file )
Hi @satmandu , i did and then removed yunbridge from the build ( I don't use it at all - i use SPI to speak to the ATmega ),
Ok that's interesting. Do you use anything besides the default avrdude configuration to write to the ATmega? Any suggestions on a good way to get data out of the ATmega without bridge using SPI?
(Any specific arduino libraries that you find useful for that?)
I put the AVR into SPI slave mode and "command" it from Linux like a SPI peripheral and used This old sketch as a starting point ( to drive neopixels, tho.. some simple logic negates the need for the AVR.. ) so i don't need lots of diverse commands like the Arduino bridge offers..
remember to set GPIO 21 and 26 to the right state before sending data.
/dev/spidev1.0
is created by the Yun boot in This script using the spi-gpio-custom command.
( from a ATH79 port I'm busy with ) : ar9331 GPIO : Yun function
The code was adapted form AVRdude, Reset MCU and gpio conf
gpio 21 should already be an output GPIO in /sys/class/gpio...
this snipped is a butchered version of a shell script i used.. but gives a good idea of the process to send a data to the AVR. If you need to read it would be better to use one of the Linux C application examples of SPI read and Write with IOCTLs .. but then you would need to create your own openWRT application and a good few examples can be found here
gpio export 26
gpio direction 26 out
gpio output 26 1
# our transaction
gpio_output 21 1 // 21 HIGH : enable level shifter
gpio_output 26 0 // 26 LOW : CS low to speak to the AVR
# echo -n -e '\xC0\x0F\x0F' > /dev/spidev1.0 // send some bytes
myCapp > /dev/spidev1.0 // send some bytes from a C application's output
gpio_output 26 1 // 26 HIGH : CS high to deselect AVR
gpio_output 21 0 // 21 LOW : disable level shifter
Hi! Thanks for the baud rate patch. Glad to find some others working on the OpenWrt side of the yun. I also backported the baud patch to 18.06 (4.9 kernel) on my repo.
I have pepe2k's u-boot_mod running on my v1 yun. His u-boot image for the carambola2 booted out of the box I just configured for the wlan button and leds. With this you get web image load and netconsole activated by the wlan button and CHANGEABLE baudrate. If you want to use stock openwrt rates you can set uboot to 115200 or 230400. I haven't molested by v2 yun with this yet.
Hi, I am originally a user of the Yun rev1 with linino, I used the serial link /dev/ttyATH0 to quickly communicate between the processor and the microcontroller at 250 kbps. I also noticed that my code no longer works with LEDE and Yun rev2 (while yet it works with rev2 and linino) : https://forum.arduino.cc/index.php?topic=557667.msg4174964#msg4174964
so I published a code that works under Linino but not Lede: https://github.com/vwone/Yun-Atheros-ATmega-UART-communication
So I'm looking for a solution to my problem and if I understand correctly, there are two:
The first is to apply a patch. But it seems to me very complex and will surely ask me a lot of time because I am novice.
The second, which seems a little simpler, is to use the SPI.
According to your post above @DanielRIOT: https://github.com/arduino/lede-yun/issues/4#issuecomment-462707702
I wrote an exchange program between the processor and the microcontroller:
https://github.com/vwone/Yun-Atheros-ATmega-SPI-communication
Sadly :
Unlike my UART code, it works with Lede but not with Linino,
it does not handle the frames because the transmissions are byte by byte,
and it does not reach the requested speed (0.6 MHz instead of 4 MHz).
Could you please @DanielRIOT share your SPI code?
In parallel, I will try to follow these instructions to apply the patch with Ubuntu or Debian stretch : https://github.com/arduino/lede-yun/issues/4#issuecomment-459816752
Thank you for your feedback.
Hi @vwone , Applying the patch would require you to rebuild openwrt, its fairly simple once you get the toolchain set up but can be daunting the first time round. Setting up toolchain, using patches , make sure you update the device with the new bootloader ( easily via the Yun-go-updater ) or change the boot adress after you've updated the openwrt image with your built one.
regarding the SPI communication :
I don't know if the Linino branch has this file, but in the Arduino Yun branch it isn't defined for Linino so if you load it it wouldn't create the port. You can run it manually, or add it in your system in one of the startup files in etc/init.d.
Arduino Yun schematic ( doesnt show AR9331 parts, but shows where GPIOs go)
insmod spi-gpio-custom bus0=1,11,27,8,0,125000 : would have SPI1 with MISO=8, MOSI=27, SCK=11, CS is manually handles via sysfs - GPIO 26 on Yun, max SPI freq = 125 kHz) source here
I think this would automatically give you the /dev/spidev1.0 ( you might need kmod-spi-dev module too )
I usually prefer creating my own frames : [STX], [frame size], [Payload 0- 255], [ETX], [Checksum] - a habit form working with Rf modems or Xbee in API mode, even if i only send 10 bytes. if the frame size is one byte the payload can be up to 255 bytes and i can allocate a static buffer in Arduino for 259 bytes with a state machine parser so there can never be an overflow and i don't have long delays :D.
Unfortunately I have not found a bitbanged UART for the AR9331, and it only has 1 UART which I use for Console and I have not tried adding another CS to the hardware SPI ( which is used for SPI flash access - it runs at 25MHz :D ), so we're stuck with:
bitbanged SPI : using spi-gpio-custom
bitbanged I2C : using i2c-gpio-custom
or the console UART with Bridge - or disabling console output and using the regular UART- like in your arduino forum post )
I'm poking around making a ATH79 port of the Yun so it uses devicetree and is compatible with all the upstream fixes in openwrt- this is still a while away, but I have a working devicetree...
@DanielRIOT Did you ever get any further with your ATH79 port, since ar71xx is now source only on OpenWRT?
@satmandu , I have a working Devicetree that brings the Yun in as a ATH79 device - I hav etnot tested any of the Arduino specific applications ( the "desktop" web interface and yun-bridge ) as I dont use those at all - Yun is a readily accessible AR9331 platform for me.
I'll create an openwrt branch on my other ( non work ) repo and link to it from here that only has Yun changes ( I have about 5 different devices that have very specific hacks / fixes which won't be accepted in openwrt ). Then we can submit a pull request to openwrt for integration for ATH79 Yun
Have you had any time to get that ATH79 yun branch up?
hi @satmandu There is currently a PR on teh main Openwrt repo to port Yun to ATh79
Thanks for the update. I've retired my Yun at this point as the flash memory on mine seemed to be getting to be unreliable, but I'm glad that people are keeping this hardware alive.
Hello, I am a casual user of all three versions of the YUN. The Rev2 has a peculiar arduino:blue:wlan LED malfunction. The arduino:blue:wlan is preprogrammed - somewhere - to remain on steady when the WLAN is active, connected or not. I have tried multiple times, In LUCI, to set the blue LED function to netdev. wlan0, trigger "tx rx" or just "phy0rx" and observe the code changes in the /etc/config/system file. However after about 30 seconds it reverts to the original steady-on condition. The system file does not change. afaik, this has been a default since it was new two years ago. I can add the white function, as shown, and the white LED continues to function as configured. Help to get the setup configuration to work is appreciated. Thank You for your interest. The OpenWrt forum seems more active than the YUN on arduino.cc. Lastly, It would seem this quirk would fall under the category of doing a pull request, Not being a programmer per se , I wouldn't have the foggiest how to be proper about it. Help is requested. Thanks. system.txt
Im trying to build OpenWRT for YUN rev-2 board. When i type make menuconfig the sub-menu shows "Arduino YUN" in the settings, is that for rev-1 board or rev-2? because it doesnt say which? Does it work for both board revisions because i have both but i want to use rev-2 now.
Wow, no response, awesome!! why is there so many different versions of OpenWRT YUN, how are we supposed to know which one to use? This repo hasnt been changed since 2018, is this the correct repo, or is it http://github.com/openwrt/openwrt which also has ARDUINO YUN in its menu?
I'm not sure what the electrical / connection difference is between Rav2 and the original one, but there are differences between this repo and the Openwrt "base" one, mostly :
You can flash a Yun with base ( probably recompiled using their build system from ar71xx or ATH79 if its been ported already ) OPenWRT but will have to play around with some of the firmware on the 32u4 to get to the linux console ( set it to 9600 baud if 115200 or 250000 don't work as the driver in linux falls back to that if the uboot bootargs tell it to use an unsupported rate ) - look at the arduino code for the yun-serial example, you will have to add 9600 support..
Hi, what are the differences between this repo and the one from Openwrt ( LEDE ) 18.06 in terms of the Yun's configuration, especially the serial console interface ?
I've built an image form 18.06 and it boots but seems to reconfigure the baudrate at some stage during the kernel boot ( it starts at 250000 baud and one can see kernel messages then after about 2 seconds it goes to 9600 baud )
stty reports that 250000 is an invaid baudrate, but this can be set by manually running
after boot ( from SSH ) or in rc.local.
How is the console configured in this version vs what is done in the mainstream Openwrt one so that the serial console works from this image , but not from the other one ?
-Ive also included the yun-config and yun-scripts in that build and built them into the kernel [*] and not as modules.
a forum post on is here, but no luck with Yun specific information from their side : https://forum.openwrt.org/t/arduino-yun-uart-console-baudrate-issue/19002/5 -Daniel