Posts

Showing posts from September, 2018

blackmagic part 2 : Software under linux

The blackmagic will show itself as 2 ttyACM devices They can have different names depending on what is connected to the system To solve that, following the blackmagic wiki, the simplest is to create a file in /etc/udev/rules.d/10-blackmagic.rules containing                                           SUBSYSTEM=="tty", ATTRS{interface}=="Black Magic GDB Server", SYMLINK+="ttyBmpGdb" SUBSYSTEM=="tty", ATTRS{interface}=="Black Magic UART Port",SYMLINK+="ttyBmpTarg"   Reboot or use udevadm trigger  , replug the blackmagic and you should see two  devices  /dev/ttyBmpGdb and /dev/ttyBmpTarg These names will stay the same Next, let's write two simple shell scripts to make our life easier : blackmagic.sh: This will flash the file given as argument #!/bin/sh export PORT=ttyBmpGdb ${PREFIX}arm-none-eabi-gdb -ex "target extended-remote /dev/$PORT" -ex ...

Building your own blackmagic using cheap bluepill board

Image
Let's build a nice bluepill based blackmagic debugger. why is it worth it ? because it makes it possible to debug a stm32 sw using your usual gdb / gdb frontend VERY easily Shopping list * Bluepill from ebay * 3S1P battery connector + wire Firmware First you need to flash the board with "bluepill" blackmagic firmware. It does not compile out of the box, there is a bad merge with a variable renamed from "speed" to "baudrate". The simpler is to get binaries from this post on the stm32duino forum. There are 2 files in the zip : * blackmagic. bin : main executable, address = 0x8002000 * blackmagic_dfu.bin : Boot loader, address  = 0x8000000 You can flash them using a stl-linkv2 clone from ebay on linux using st-flash write blackmagic_dfu.bin 0x8000000 st-flash write blackmagic.bin 0x8002000 Verifying it works fine : If you plug it through USB, you should see 2 serial interfaces, ttyACM0 and ttyACM1 and an openmoko device ...

Weird LM358 (clone) behaviour, output rises when difference amplifier goes negative

Image
That one made me scratch my head for some time. It happens when we use a voltage difference scheme All of a sudden, the ouput raises while the difference is zero or negative i.e. with all resistors = 1k When v1=0, and v1 > v2, Vout is raising instead of being zero WTF ? It boils down to two lines in the LM358p datasheet : * "Output  Source : 40 mA" * "Output Sink : 50 uA with low output" What does it mean ? If the OpAmp outputs current, like a simple non inverting amplifier, it will max out at 40 mA. So with a 1k Resistor, 40V. Not a problem But, in the case of a difference amplifier, it might want to lower the voltage compared to the "-" pin In that case, also with a 1k Resistor, it can lower by 50 uA*1k = 50 mV maximum ! It means that if the "-" pin is higher than 50mv compared to the + pin, it will pull the output up Example: -Pin=3v +pin=0v Output should be zero, it is ~ 3v. How to fix it ? Simple...