I already have several GPIB boards on my desk. Actually I have 1.0, 1.1 (and now 2.0) version of my board. One of the 1.0 boards doesn't work correctly. I meant, I need some diagnostics into the firmware to track down the problem. So I wrote a diagnostics extension to the current instruction set. It is able to manipulate the GPIB pins directly (I tried to resolve the error of this board, but the results were inconclusive).
To step forward, I soldered in the next generation board. It also need some software modification as it use ATMEGA32U4 instead of the ATMEGA328P on the previous one.
Everything went easy. Too easy.
The ISP programming was successful immediately. The software modifications took less than five minutes. The board upload worked, just right after fixing one single easy to handle bug.
Connected to my test HP3478A multimeter. Run a scan command. It immediately found the instrument and reported back the reading. The only gotcha was the reading characters appeared one by one slowly.
Next day - troubleshoot
I was thinking one unsoldered pin, and reading timeout cause the problem.
Fired up the diag mode, and realized that the D1, IFC, SRQ and ATN always reporting back high logical level, whatever I do.
Tracking down the issue - playing with the other boards - just came out, that the diag mode doesn't handle certain pins correctly. Modified the diag mode. It resolved the issues on the 1.0 and 1.1 boards, but not on this one. The D1 and the ATN issue remained.
Later on, somehow I figured out that those are used on the Arduino Leonardo board (what I was using as configuration and the bootloader of it) as RX and TX LEDs for the USB communication. Holly shit.
Redesign or fight?
The dilemma came here. I've two options:
Either I redesign the board, and send to manufacturing once more, or fight with the Ardunio bootloader, core, whatever. I chose to fight. Reasons:
- Design and manufacturing has costs, and need several days (or even weeks) until the new board arrive
- The ATMEGA32U4 has two externally accessible full 8 bit ports. Those can be used for faster communication with direct port manipulation. Unfortunately those LEDs are use one pin of each of this ports. So if I don't use them, I lose the speed here.
- Digging deep is fun. I can learn a lot from it.
Blame the bootloader
Actually I don't know why, maybe I read something on a forum, I was thinking, I need to modify the bootloader, and it will resolve the problem (maybe the serial use it for the communication, I don't know)
First of all Identified the source code of the bootloader. It is located here (https://github.com/arduino/ArduinoCore-avr/tree/master/bootloaders/caterina). Checked the Makefile it also need a library called LUFA for the USB communication. I also checked this out. Added the latest Win64 compatible avr-gcc and make.
I tried various ways to point the Makefile to the LUFA, all of my attempts failed. Also it missed grep tool. I felt like the Windows is a dead-end for this build.
Switch to Linux
Didn't wanted to build a linux machine, or add a Hyper-V based Linux. So I fired up the Subsystem for Linux and installed the Ubuntu 18.04LTS from the Microsoft Store.
Installed avr-gcc, build tools, make, etc. on it.
Found the filesystem location of the Ubuntu in the Windows filesystem and copied the source code over.
It wasn't work. I got various permission issues with the copied files, so I gave up and cloned the repos once more.
Trying to compile gave the same errors as on Windows without the grep problem. After several path modifications, adding the USB VID and PID finally it started the build. The result was a catastropy:
The bootloader in question was built last time 8 years ago. Both the avr-gcc and the LUFA library stepped forward since.
Figured out what tag was used originally, switched the repo to it. Now the bootloader compiled successfully.
Testing with the new bootloader
I didn't wamt to hack it into the Arduino IDE so I flashed the bootloader manually to my board. Uploaded the code also. And....
and it failed.
Hack the core?
No. Even I figured out that the problem is probably in the USBCore.c, I didn't wanted to hack it. It wouldn't create a future proof solution.
Looking around and thinking lead me to create a custom Arduino board specification for my project.
New board config - not yet
First of all I wanted to have something I can learn from. I found an ATMEGA32U4 based custom board from ArachnidLabs (http://www.arachnidlabs.com/tsunami/), and the git repository for it: https://github.com/arachnidlabs/arachnidlabs-boards
It turned out immediately that I need a stable place to to host the json and the package zip. Something I can count on that will be there for a while. Something can be accessed without any authentication voodoo (like OneDrive).
As the AVR-GPIB project of mine hosted on GitLab, I was looking around there. As Github has Github pages, what a surprise, GitLab has GitLab pages.
I read through the documentation, it was still not clear, how to setup the GitLab pages.
Created a repo named suf.gitlab.io, put the files in there. Nothing happened.
Ok, it looks like I need a gitlab-ci.yml for building the site. This isn't surprising concept to me, as in the last few years I'm working as DevOps engineer. Writing Jenkins CI/CD pipeline scripts on daily bases.
Wrote the script, pushed the repo, failed. Some naming wrong. Corrected.
Next. Building correctly. The site still give 404 back.
After many tries realized, that my files from the GPIB subdirectory landed into the root of the site. I was thinking that it is because the root has no files in it, just the GPIB folder. So added an index.html.
The previously successful build failed again.
After reading many things, several trials, came out, that the only approach what is working, to add everything to a newly created temporary folder and rename (mv) it to public, what is the designated name of the publishing.
So my GitLab pages site born: https://suf.gitlab.io
It is small, it is yellow, it is sour, but ours (I know it is not got through in English, as it refers to an epic Hungarian movie from '69 - https://en.wikipedia.org/wiki/The_Witness_(1969_Hungarian_film)).
New board config - now really
Created the json, modified the pins_arduino.h (pointing the LEDs to two not externally exposed MCU pins), built the package, created the hash, added into the json, uploaded the whole thing to the GitLab, added the json to the Arduino IDE, went to the board manager and...
Repaired two things looked like bug: name of the json. I don't know if it is a requirement, or just a kept convention, but renaming don't harm.
Realized, that I didn't change the length of the package file in the json, so now I did it.
Push to GitLab, back to Arduino, my config appeared in the Board Manager
Install: failed. There must be a single folder inside the package.zip.
Changed the required things, push to GitLab. Install now works.
Try to upload the code I wrote.
Getting weird inconclusive errors, communication problems. Switched back to Arduino Leonardo, getting the same errors. It smelled like problems with the Windows COM handling. Reboot resolved it.
Try to upload once more. There are missing avrdude parameters. Various parameter related issues. Finally I added into the package.txt whatever I found. It looks like that the ArachnidLabs config was written for an earlier Arduino IDE what doesn't require those parameters.
Now the board upload works.
Try it out
GP-IB diag functions now work as I expected. We are ready!!!!
The diag works, the communication with the instruments, not. Enough! Sleep!
It was something itching in my mind. Tried out the previously working boards. Stopped working those too.
Either my HP 3478A multimeter died, what I'm using for the tests, or the diag modifications what I did in the code later on, disrupted the communication.
Figured out soon: the diag was buggy. Fixed it. Now the v2.0 board works.
End of this story.
Will continue with the further hardware and software development of the GPIB adapter.