[StabiloRose] VBUS

Today, we started to code for our board. The switching power supplies are working well and controlled by the STM32. Interrupts are generated if they are not stable. Everything went fine… Until we tried to implement the serial over USB module, and the shell. We were stuck for a loooooong moment. Impossible to obtain anything. It was like the STM32 was not connected to the laptop. We confirmed that it was not an hardware issue by communicating with the preinstalled USB bootloader of the STM32.

After checking the schematic, we (Thanks for all Dryvenn) pointed out the problem. The PA9 is the default pin for VBUS. Ours is connected to the buzzer, with a pull-down resistor. As the STM32 couldn’t detect if any cable was plug-in, it have never engaged the communication.

The problem is solved by defining the symbol BOARD_OTG_NOVBUSSENS in board.h. Now we have to manage the cable detection “manually” with interrupts.

 

[challenge] What a day !

I had imagined many scenarios for this day, but certainly not this one. To answer your question Drix, yes the progress animation was there. It was funny, but also very destabilizing. Could you imagine that in the preparatory exams for the Grandes Ecoles ? Every one becomes crazy ! On the one hand it is very stimulating and emulates the competition. On the other hand, it reassures you. I was not the only one to be stuck at step one in the afternoon.

In fact, my code was not robust enough and I spent many hours on debugging it. Then, I had a revelation around 5pm, which gave me only a few hours to progress on the challenge. I can still remember Sam’s eyes saying “Another one who haven’t listen…”, when he was checking my work… And he was right. After cleaning all this, the coding was more fluid. It brings me out of my grumpy mood and my bad faith.

Above all, the challenge really was a good experience. I understood a lot about debugging, and errors management in particular. I must correct the code of the practical work and make it clearer now. The more I use ChibiOS, the more I enjoy it. There is a big step to understand it in the beginning. But it turns out to be very powerful and easy to use.

At present, we have to focus on the code of our project… but not tonight.

challenge

[ChibiOS] What a day !

Today was a big day. I had to finish the implementation of a simple http client before the challenge of tomorrow, to get familiar with the LwIP stack and the netconn API. It’s almost done. I haven’t tested it with telecom-paristech.fr because the site was down for a few hours this afternoon. I tested with my laptop as a web server, only with netcat. I received the http get and the response was correctly redirected on the serial over USB channel. By the way, the port 80 seems to be blocked on the computers of the a406 room. I mean, with netcat listening to the port 80 on my laptop, I couldn’t established any connection from another computer in the room, even if both were connected with Ethernet.

I’m not inspired tonight, so I am going to continue with these little mistakes or, let’s say carelessness, I made today. The first of all dealt with endianness. I only used static IPs, so I hardcoded them. This was a really bad idea. With a little-endian processor and a big-endian network, you could imagine the disaster. Then I worked with the echo server set up by Alexis. After a few tries (at least one hour), the communication was impossible. The server was down. About this point, I plead guilty.

But this is nothing compared to the netconn API documentation. Between the ambiguity of the explanations, the broken links, and the “@todo explain netbuf”, I was completely lost. I allocated memory for the buffers where I should not, I used functions reserved to UDP…

Anyway, this is over. I give you another funny picture, from Geek & Poke this time.

Endianness (from http://geek-and-poke.com/)

[ChibiOS] Multithreading

After the anger comes the frustration. After being stuck a few days on the serial over USB implementation on ChibiOS, I finally did it ! It was yesterday evening. I was in a good mood this morning. Actually, making a success of compiling and flashing a demo code is not very glorious. The rules are clear : no black magic ! However, after many comparisons with my original code, I could not figure out where were my mistakes.

The general survey and advice of today have been helpful. My problems came from the multithreading. Firstly, I thought that when main returns, it would be sleeping forever. In fact, it seems to be stuck in an infinite active loop. Because of this active wait, the serial over UBS, which had the same priority, could not be executed properly. (The management of SDU was made in a thread, not in the main function) Instead I saw a lot of 110 errors in dmesg. 110 means “not enough power supply to provide to the device”. It logical from the point of view of the host. The STM32 acted like it was establishing a connection, and stopping. And started a new one and so on, like a device which is constantly rebooting because it not powered enough.

A few patches later, it is now working properly. I am pretty impressed by the shell. It is very easy to enable and customize. You can add you own commands, see the number of threads, the state of the memory. Very useful.

Well, I hope I will remember this episode during my future debugs. I leave you with this picture you might have already seen.

Multithreading

Multithreading: Expectations vs Reality

 

Getting Sidetracked by Interesting Protocols

Today, I lost a lot of time.

Actually, I didn’t lose any time, I just didn’t use it for what I had intended in the first place. I hoped to finish the assignment within the deadline, that is today; instead I learned a little about USB and standard libs.

I started by trying to use the serial-over-usb module of ChibiOS, but faced with the complexity of the USB protocol, I ended up adapting the demo code rather than reconstructing it. To my surprise, it didn’t work ! That is, even when only compiling the demo code, it would compile fine, but never actually expose a recognizable device to my computer . Instead, I would be getting confusing “device descriptor read error” messages in my dmesg, and packet inspection via wireshark/usbmon indicated that the packets were malformed. After some fiddling about and dirty “switch the usb off and on again until it works” hacks, I could see the device descriptor, but not its configuration, so still far from a serial-over-usb communication.

After a few hours of hair pulling, I switched workstations, and it worked on the first try, with the exact same code, only a different compiler ! I guess I’ll be sticking with the official ARM toolchain from now on, to avoid any unpleasant surprises like this.

In the end I still learned some basics about the USB protocol, and I also tried to make ChibiOS compile with clang. I have no more compilation errors, but it’s still not linking unfortunately. I guess this little side-project will have to wait, though, because I still didn’t finish the assignment in the end…

Practical work

The diagram of our project is almost finished. Today, I have seen with Alexis what I have had to do with Vbus from the USB. We don’t use usb to supply our pcb however the STM32 need to be connected with the Vbus in order to know that there is a USB connection. I have changed the diagram.

I was working on the practical work. I have succeed to debug the demos application. Now, I am playing with LED’s. I have got just one problem. Firstly, I have forgot to press the reset button and nothing have worked.

Eric

Soon… placement and routing

Hi !

Since a few days, the Expelliarose team has worked on the schematic design of our card. Now, most of the components that we have ordered are available in the Expedition PCB libraries and thus, we can start placing and routing them.  We will also have to choose the shape of our PCB, which will probably be a bit special, because it has to match with our wand design.

At the same time, I have begun to get more familiar with ChibiOS and the STM32 processor thanks to the Olimex board. I currently deal with the PWM control to manage easilly the LEDs intensity.

A begin with the stm32

Hello,

I had some trouble with my computer and I was not able to compile ChibiOS. Too much time losing because of some library missing.

Problem now fixed, and that allowed me to make my first flash on the olimex card, and also to make a thread to control LED.