-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bootloader problems #28
Comments
can you ping a simple test sketch that just setup your ethernet device?
you can use the make file to compile a debug vresion.
or just see what the make file do and do the same in your code (hint: some symbols should be define for enable debuging). |
If I understand the scheme of your hardware, this setup seems wrong to me. see the code from spiInit:
but, you don't need take my advice here about the pins setup. It is no so hard to setup a basic environment on windows box, just get the following 3 tools:
they all freely available (just google it). after you set them up, let's say under C:\Tools\ folder, create a batch script like below:
you should find now in the same folder a compiled hex files. if you successfully compiled the code, now it time to start explore & introduce changes :) Happy Christmas |
Hi, I also try to flash a Controllino Maxi with this bootloader. Did you find a solution to your problem? Thanks in advance! |
Hey jkroeze, I'm gonna try to see if I can get this to work this week, I have a couple of other things I need to fix also, but I'm going to prioritize this now because I really need it :) How far have you come jkroeze? |
Hi, I fixed it, but not with this version. This version doesn't let me upload sketches through the serial port. The problem is probably related to the onboard RTC. When I inspected the source code from the Controllino Ethernet library i saw they put the RTC SS pin (PORTJ2) HIGH. I modified the bootloader (spi.h and spi.c) to do the same. I also changed the ETH_SS pin to PORTJ3. I attached the modified files and a compiled hex file:) Good luck! |
Hey jkroeze, And then both the per1234 and the loathingKernel works with ETH upload? While loathingKernel version does not work with serial upload? Am I correct so far? I think I read a thread somewhere here earlier about increasing the packet size to allow Mega2560 to be serially programmed as well, or perhaps that was for the ETH programming.. I have to look that up, but perhaps you know or someone else know of this already? Now I got even more enthusiastic about programming the Controllino with the bootloader, I think I will have some time over tomorrow wednesday to fix with this.. Not saying that I "knew" it or anything, but I think I was on the track with the pins earlier that it might be the wrong pin used for the selectpin.. But I guess you beat me to fixing that :D I wouldn't have found that so fast either, I guess ;) So, great work! |
Hey again, Using the Arduino IDE, I can install the library/board thingies through the Board Manager without problems. However, programming my Controllino MAXI with an ATMEL-ICE via ISP does not work. I get the following error;
And it seems that more people have the same problem and there is no direct solution.. So, headed over to Atmel Studio 7 which has no problem programming the Controllino though the ATMEL ICE and over ISP. I can successfully program the unit but I still get the "freeze" of the Controllino MAXI after startup. I both tried the HEX file that you included in the ZIP file, and I've tried with the complete clean code as a new project - just replacing the spi.c and spi.h files - the ones you had updated. I still get the same "freeze" of the Controllino MAXI unit. With freeze I mean that D2/PG5, D8/PB4, D11/PB7 are lit (LED's connected to these on the Controllino MAXI). There seems to be no direct activity on the network port and nothing else seems to happen. I can't seem to ping 192.168.1.128 either, my LAN is setup for 192.168.1.x - so the unit should be able to cozy around on the network. The computer/server I'm trying to talk to my Controllino with is a Linux Debian machine, with no restrictions when it comes to firewalls and such. The computer/server and the Controllino are the only ones sitting on the same LAN. The router used for this separate network is an Edgerouter, but the "firewall" part of the router should most certainly not block the tftp traffic within the LAN. There are also no DHCP addresses dealt with, but I guess that's fine as the Ariadne bootloader by default wants 192.168.1.128 as an fixed IP. My computer/server is using 192.168.1.5. I'm not sure if the "gateway" as found in the code of the Ariadne bootloader, should be the tftp computer/server? If so, why would it be default set to 192.168.1.1 - which in 99% of cases are a real gateway? aka. router or similar. I've tried changing the source to use 192.168.1.5 as the "gateway", but seems to be same result. Also, what is needed by the computer/server? I should be able to use a tftp client on it to connect to the Ariadne bootloader, which acts as the tftp server - correct?
And after a while I get "Transfer timed out.", most probably because the Controllino is not properly connected to the network. So I can't say that I believe my unit has network connection in the bootloader mode. While the unit does have network connection when loading another sketch/program into the Controllino - compiling my regular sketch in the Arduino IDE, taking the HEX file and programming the Controllino through AS7 with the Atmel ICE. It's really interesting that even your HEX file, jkroeze, does not work on my Controllino MAXI. I think I've got all the details on how my network is setup, how I programmed the unit and how I try to connect to it. Perhaps I've missed something, compared to your setup jkroeze? |
Progress! Well.. not thanks to me I guess.. but I've noticed a difference! I've got both the Atmel Studio compilation to get network access now with IP 192.168.1.128 when gateway is set both to 192.168.1.1 which is my router, and to 192.168.1.5 which is my computer/server. But I guess it really should be the router address that should be the gateway, correct? However it doesn't matter which gateway address I specify, the Ariadne bootloader doesn't seem to answer at all. Another thing I've noticed is that the Controllino when started isn't responding on ping until after 10 seconds. After this period it responds to ping like normal;
It also crossed my mind to check with you guys if my fuses are correct, if perhaps you guys have changed them on your projects?
I tried enabling debug today and all I get out of it is, continuously;
Using 115200 as baud and ASCII. When using HEX presentation instead, I get 0xFF I've tried enabling debug for each and all of the following;
Same thing happens for all, except when enabling it for main, the program also stops before the LED's are lit. I have also, with the above defined the following to enable debug
I have also tried the following and I don't get the proper output on any terminal program;
More or less random crap is coming out, sometimes its the same output but far from always.. Quite strange I guess.. The commands I use for tftp are the following, compiled into an .sh file on my Linux system
With that I get the following;
Finally, I guess that the LED - specified in spi.h (LED_DDR/LED_PORT/LED) should blink with the main loop in the file main.c through the use of updateLed(); function. Either it does blink but extremely fast so it looks like its always on, or it never blinks. However, it does cut out every ~6-8 seconds - when the WDT resets the unit as it should without a userprogram uploaded. I found where the program is during the course of the ~8 seconds before WDT resets the unit. I can find this out if I run this "modified" sockInit(*) function;
When I run this modified version the LED blinks rapidly until the WDT resets the unit. This means that everything in the main loop in the file main.c is not run after this part;
Is this wrong or should it be like this?? |
More progression! Starting to become a long monologue here ;) I found that if I remove this part in file spi.c, from your file jkroeze
Or the following from the file spi.c, when using the loathingKernel project
The bootloader does not stop at the sockInit(*) function. It now runs on and responds directly on pings, however the upload does not seem to work still.. Another fantastic discovery is that the bootloader from; Is there something special I need to do with the user program? It doesn't have to be a specific size either right? As far as I can tell I should be able to upload an Arduino sketch (tried a regular Blink sketch) after converting it with avr-objcopy. I've used the following command to do so;
Any help on this would be, of course, much appreciated :) I'm so happy with the progress I've made so far and I got the unit to finally be "online" and responding at least. Now there is only a small step, as it feels like, to get to the finish line :) |
An update on the previous, just to show the TFTP communication This is with the per1234 version of the Ariadne Bootloader, shouldn't there be something else after the part with "Sent 2436 bytes in 4.0 seconds [4872 bits/sec]" ? Like restarting, completed, starting user program or anything?
This is with the LoathingKernel version of the Ariadne Bootloader
|
No, the messages you see are from your tftp client. Ariadne doesn't sent anything back except for errors, so you shouldn't see anything other than that. AFAIK, @per1234's fork doesn't touch the bootloader code, other than adding atmega1284P support, it is in its entirety an older version of this repository with conveniences for arduino IDE. If one works for you and the other doesn't, start by looking at the commit history to see what has changed. |
I tried an earlier version of the loatingKernel variant, dated June 2017. This is "about" the same date that I use from per1234 and still the same problem. So I guess the difference is in an even earlier version, if your version at all will work on my hardware. Is there any possibility to do check on Github directly between two projects? Or is my only solution to use a difference checker tool to just go through file after file? :) |
I think loathingKernel is correct about the bootloader differences, though it's been so long I really don't remember. Comparison of my fork to this repo: Another difference might be in the compilation of the bootloader. My hardware package provides .hex files, which were compiled with the version of avr-gcc included with the Arduino IDE at that time so maybe you're using those .hex files? I'm guessing you're compiling the bootloader in this repo yourself. Another consideration is fuses. You should verify the fuses are the same in each case. Application not starting can definitely be caused by misconfigured fuses. |
Thanks for coming here and replying as well per1234! :) Both the per1234 and the loathingKernel version is compiled in Atmel Studio 7, burned with an Atmel ICE through AS7. I wanted to get everything working directly through the Arduino IDE, and sure enough the download through board manager works and all that. However, for some reason (more people have the same problem without solution, as far as I know) the Atmel ICE does not work with the Arduino IDE, at least not if you have AS7 installed. The fuses should be the same, no matter which project, but just to be sure I checked them and they are
The bootloader program in both cases are starting and they get online so that I can ping them. Its just after the per1234 version has received the file it doesn't start up the uploaded binary file. loathingKernel version doesn't even respond to TFTP connection. So, I guess that this shouldn't be due to wrong fuses, but in that case you guys know more than me :) Also, you're mentioning .hex files. Well if I burn one of the hex files, I think only the ones from the per1234 repo, I can even get the debug working. However, as the pinout is different in the spi.h file the W5100 isn't started so I don't get any network connectivity. But when trying to enable debugging in either of the two repos, when compiling it in AS7 I only get crap out on the terminal. Also, if I define debug main, the controller locks up before the led lights up, and no network connectivity.
Of course, I've tried both with and without defining;
If I could get the debug, or even the serial to work I could at least find if the loathingKernel version sees any incoming connection, or if the per1234 version validates the binary file and is ready for restart or whatever. I've also put the following in all files where delay.h is included to see if that helped, as it could be a speed issue when the serial line isn't working properly, but without any positive result.
Furthermore I've tried to lower the baudrate but no difference there either. I don't really know what else to test.. I guess my only bet now is to compare the repos and see if I can find something.. But at least it would be good to know if the per1234 version at least saves the binary correctly, or if its just bogus that comes in/out. I don't have to do anything special with the binary file correct? I've tried the following two commands to create the binary file, after it has been compiled by the Arduino IDE, just a simple blink sketch for led on D0.
|
I haven't really understood the comparing thingies yet, still working on that :) I think I just need some time to get used to it. However, I've changed the serial.c/.h files with code that I know works, so now I can get some debugging done. I jumped directly to the validation of uploaded image and found that I get the following error;
That could most certainly be a problem ;) Do any of you have a simple blink sketch that you know work on your Mega2560 targets? I know that when I use the normal Arduino bootloader, this following sketch works and blinks the same LED as the bootloader, but in a much slower frequency.
That is also the exact same sketch that I compile, take the elf or hex file and convert it with avr-objcopy into a binary file. But perhaps I'm doing something wrong there.. If any of you could compile that one, if you have time and feel for it of course :) then I could test that to see if perhaps my compiling isn't correct. Many thanks for all your help and support so far! I really appreciate it!! |
Just disable validation while you test. Validation is based on certain patterns that exist(ed) in the generated binary. In recent arduino versions, due to compiler flags probably, those patterns might have changed. |
Aha! I will have a go at it this weekend and see if that helps, didn't even think about that. I guess I thought that it was completely necessary only due to errors in upload or something. But that sounds resonable and I now understand how it works, so shouldn't be too hard to disable it :) Many thanks! |
I had many problem with the serial bootloader.. so I changed it to work like in Arduino project. |
The two methods are supposed to be equivalent (as in achieving the same result) according to the datasheet, but if one works better than the other on certain cases, it should be brought back.
I am more interested what you mean by this. |
Comment been update, it is mean it was not pushed to the public repository. |
the difference, and where the problem coming from, is from the timing of the sending loop(while loop). in my testing, sometime the last byte was getting "lost": avrdude was never seen it, and emits errors. |
As it was worded, it wasn't clear to me if by private you meant your local repository, or some other private repository. Since the project Ariadne was forked from is GPL, we have to adhere to the GPL, and that is why I asked. |
** Sorry in advance for the code blocks with no newlines, I can't seem to get them formatted properly..? **
Hey there,
First off, everyone who has worked with this in the past, big Thanks! :) Also to loathingKernel for your wonderful continuation!
I'm having a look at this bootloader as I would like to use it for programming a couple of units in a remote location.. Which this bootloader should be able to do, which is great :)
However, I'm having a few problems.
Which software are you using for editing and uploading the bootloader to the target?
I've tried Arduino 1.8.3 which seems to be a no go. I've tried to put the "hardware" and "libraries" both under /arduino/ and also in the /arduino path, but also in the "C:/program.../arduino" path but I just get errors that the board.txt file can't be read and similar. I can of course provide more errors when I'm told exactly where the files should be put, but as of right now, when I follow the Readme file, it just doesn't work.
I've also tried Atmel Studio 7 which can compile the code, create an HEX file and upload it to the target. However, I still can't ping the device either on the default IP which ends in .128 or the IP I've set which should be .33
I've edited the net.h file with my network settings, like the following;
/ Network settings /
#define IP_ADDR 192,168,1,33
#define SUB_MASK 255,255,255,0
#define GW_ADDR 192,168,1,1
#define MAC_ADDR 0x55,0xD7,0x53,0x00,0x01,0x0B
But, I can't ping the device on this address. The Gateway address I suppose should be the real network gateway, such as the router, correct?
Also, how do I enable debugging in the source code, so that it outputs data to the Serial port, just like the "ariadne_debug2560_w5100.hex" file does when it is uploaded?
When I upload the bootloader file "ariadne_debug2560_w5100.hex" I do get debug output and the IP address is set to 192.168.1.128 - which by the way is matching my network and it is a free IP. I still can't ping the device though.
The device I'm using is actually an Controllino Maxi. This device is based off the Atmega2560 with a WizNet 5100 chip. The following are the pin connections which is hardwired and can't be changed in any way.
Arduino 52 / PB1 - WizNet SCK
Arduino 51 / PB2 - WizNet MOSI
Arduino 50 / PB3 - WizNet MISO
Arduino xx / PJ3 - WizNet SS/CS
I've thought that maybe the PJ3 should be configured in the spi.h file as the chipselect, but not sure if that does anything? I've tried changing both #define SS and #define ETH_SS to PINJ3, but no change in response from the unit on the network.
Something I've noticed is that the PINB7, defined as LED in spi.h, the led is not flashing or blinking, just solid on.
Also, I don't see any traffic on WireShark that could be the bootloader. But I guess thats only when inbound traffic is active. The bootloader isn't transmitting anything without an incomming call, right?
Pinout for the Controllino, Ethernet chip just right of center on the pinout sheet, below SD card connector..
http://controllino.biz/wp-content/uploads/2017/05/CONTROLLINO-MAXI-Pinout.pdf
I think that is all for the moment, would it possible to help me out in any way? :)
Edit..
If I run the debug version of the hex file "ariadne_debug2560_w5100.hex" available within the Git download I get the following output on the serial line;
Main: Ariadne for Arduino Mega2560, Version 0.5
Net: Built-in settings
Net: Address: 0xC0.0xA8.0x01.0x80
Net: Subnet: 0xFF.0xFF.0xFF.0x00
Net: Gateway: 0xC0.0xA8.0x01.0xFE
Net: MAC: 0xDE.0xAD.0xBE.0xEF.0xFE.0xED
Net: Network init done
Tftp: Init socket to port 0x0045
Many thanks in advance!
// Christopher
The text was updated successfully, but these errors were encountered: