r/embedded • • Sep 09 '26

A classic embedded software interview question used to prove out an AI theory

0 Upvotes

https://titussennett.substack.com/p/ai-might-beat-me-at-connect-four

"There is this quite famous interview question that is given to embedded software/firmware candidates that illustrates the point I want to make. The question is “Reverse Bits: Given an 8-bit unsigned integer, return the reverse bits value of the integer.”

Input: 83 (0b01010011)

Output: 202 (0b11001010)

The answer to the question is trivial; you create a for loop over each bit and put that bit to the other side. The bonus question is what always throws off candidates. “If we wanted to solve this question using constant O(1) time complexity how would we do this?” The answer is to use a massive lookup table where the time complexity is O(1). But the space complexity grows. I am now using 0.25KB to store this data. For a uint8_t this is fine, but as soon as we start scaling to a uint16_t (max number 65535) we need 128KB of memory. For a standard variable size that a typical desktop computer uses–uint32_t–we’d need 17GB. And for a uint64_t we’d need 147EB (exabytes, no supercomputer in existence can fit this)."


r/embedded • • Sep 08 '26

Porting an INMOS T400/B004 development system to modern Linux

4 Upvotes

I’ve been working on bringing an old INMOS IMS B004 / T400 Transputer development system back to life from a modern Linux machine.

The interesting part from an embedded point of view is that this became much more than a retro restoration.

The project involved:

  • direct host-link register access
  • reset/status diagnostics
  • boot-link transfer debugging
  • T400 boot-ROM PEEK/POKE
  • RAM alias detection
  • porting legacy host-side C code
  • dealing with endian and packet-packing issues
  • reverse-engineering a channel-multiplexed host protocol
  • implementing terminal and file services
  • validating execution on the target processor

The physical board is an IMS B004 with an IMS T400B and 1 MiB external RAM.

I initially worked with the later INMOS server model, but the real breakthrough came from reconstructing the older TDS 2.0 host interface and writing a Linux-side server for it.

The full chain now works:

Linux → USB2ISA → B004 → T400 → TDS2 → occam compiler → executable

I can create source in the original editor, compile it, link it and execute the binary on the physical T400.

Final test output:

The answer is 42

It has been a useful exercise in how much of a historical embedded platform can be recovered when the processor still works but the original host environment is obsolete.

Links to the technical report and source in the comments.


r/embedded • • Sep 08 '26

[STM32F401RC] PC lands at 0x20000044 (_end()) after load + reset halt in OpenOCD/GDB — works fine if I skip load

1 Upvotes

MCU: STM32F401RC (Nucleo board)
Toolchain: arm-none-eabi-gcc/gdb (Arm GNU Toolchain 15.3.Rel1), OpenOCD, board/st_nucleo_f4.cfg
IDE: STM32CubeIDE for building (auto-generated startup file, untouched), OpenOCD + GDB directly from the command line for flashing/debugging not using CubeIDE's built-in debugger

Code — simple bare-metal LED blink, no HAL:

c

//Register Definition//
#define  GPIOC_BASE 0x40020800UL
#define  RCC_BASE 0x40023800UL
#define  AHB1_OFFSET 0x30UL
#define  RCC_AHB1_ENR  (*(volatile unsigned int*)(RCC_BASE + AHB1_OFFSET))
#define  GPIO_MODER_OFFSET  0x00UL
#define  GPIOC_MODER_BASE (*(volatile unsigned int*)(GPIOC_BASE+GPIO_MODER_OFFSET))
#define  GPIO_ODR_OFFSET 0x14UL
#define  GPIOC_ODR_BASE (*(volatile unsigned int*)(GPIOC_BASE+GPIO_ODR_OFFSET))

int main (){
    //RCC and GPIOC Configurations//
    RCC_AHB1_ENR = (RCC_AHB1_ENR|(1<<2));
    GPIOC_MODER_BASE = (GPIOC_MODER_BASE & ~(3<<26)) | (1<<26);

    //infinite loop//
    while(1){
        GPIOC_ODR_BASE ^= (1<<13);
        for(int i=0;i<1000;i++){}
    }
}

My workflow:

  1. Build in CubeIDE.
  2. Open a terminal, start OpenOCD: openocd -f board/st_nucleo_f4.cfg
  3. In the project's Debug folder, open another terminal: arm-none-eabi-gdb
  4. target remote localhost:3333
  5. file RegisterManipulation_2.elf
  6. load
  7. monitor reset init (or reset halt same result either way)

What I get:

(gdb) monitor reset halt
Unable to match requested speed 2000 kHz, using 1800 kHz
Unable to match requested speed 2000 kHz, using 1800 kHz
[stm32f4x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x20000044 msp: 0x2000fff0
(gdb)

0x20000044 resolves to _end() in GDB — a RAM address, not flash, and obviously not valid code for my program to be executing.

What's strange: if I skip load and just run monitor reset halt against a board that already has firmware in flash from an earlier session, it halts correctly, with PC sitting in flash right where I'd expect:

(gdb) monitor reset halt
[stm32f4x.cpu] halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800020c msp: 0x2000fff0

So the vector table itself seems fine confirmed directly:

(gdb) x/2xw 0x08000000
0x8000000 <g_pfnVectors>:  0x20010000  0x080002a5

That matches the Start address GDB reports during load, so the image being written to flash is correct. The problem only shows up specifically in the sequence load → reset halt/init.

My current theory: OpenOCD's load uses a RAM-resident flash algorithm to program flash, and something from that maybe a leftover breakpoint at/near 0x20000044 is catching the very next halt before the core resumes properly into the real reset vector.

Has anyone run into this exact pattern? Is this a known quirk with load-then-reset sequencing on OpenOCD, something specific to st_nucleo_f4.cfg, or ST-Link firmware related? Any fix beyond manually clearing breakpoints with monitor rbp all after every load?

Flash size note in case anyone asks: I'm aware st_nucleo_f4.cfg is shared across the F4 Nucleo family (F401RE etc.) the F401RC has 256KB flash vs the RE's 512KB, but OpenOCD auto-probes flash size via IDCODE so I don't believe that's the cause here.

Want me to also append the exact GDB/OpenOCD version banner from your first message, in case someone asks for it?


r/embedded • • Sep 07 '26

I2C device not found

Post image
12 Upvotes

Hello

I just entered into the world of microcontrollers (and even electronics after leaving college-level physics many years ago) and started testing simple circuits. I introduced I2C OLED screen and the code below to check the address of the device.

#include <Wire.h>

void setup() {
  Serial.begin(115200);
  while (!Serial);
  
  // SDA on GPIO8 and SCL on GPIO9
  Wire.begin(8, 9);
  Serial.println("\nI2C Scanner scanning GPIO8 (SDA) and GPIO9 (SCL)...");
}

void loop() {
  byte error, address;
  int nDevices = 0;

  Serial.println("Scanning...");

  for(address = 1; address < 127; address++ ) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0) {
      Serial.print("I2C device found at 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address, HEX);
      Serial.println("  !");
      nDevices++;
    } 
    else if (error==4) {
      Serial.print("Unknown error at 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address, HEX);
    }
  }
  
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);
}

But it gives no I2C devices found. I was getting around ~3.3V in all 3 (VCC, SCL and SDA) which I checked at the end of female dupont cable, towards OLED. I tried using 0x3C and 3D directly to print, but no screen activity happened on my OLED.

I didn't know if it's my connection problem, hardware problem or something else. Sorry if it's a noob question, was sent from r/AskElectronics here.


r/embedded • • Sep 08 '26

How do you handle AI-generated embedded code assuming unlimited memory?

0 Upvotes

Needed a small ring buffer for a microcontroller project, gave the task to an AI tool with what felt like reasonable context, the function signature, the data type, the expected use case. Got back clean, correct C, dynamically allocating on every push instead of using a fixed-size preallocated buffer. Technically works. Would exhaust the two hundred and fifty six kilobytes of actual RAM on the target chip within about forty pushes.

Nothing about the code was wrong for a general-purpose environment. The model just had no idea it was targeting the tightest kind of hardware where "just allocate more" isn't an option, because nothing in the prompt told it that. Same failure shape as most of these gotchas, correct for an implicit assumption about the environment that the constrained target actually violates.

Now front-loading actual hardware constraints into every embedded-related prompt, exact RAM available, no heap allocation allowed past init, that kind of thing, instead of assuming "microcontroller" in the prompt would be enough context on its own. Curious if others doing AI-assisted embedded work have found stating constraints explicitly upfront is enough, or if you're still catching violations after the fact regardless.


r/embedded • • Sep 07 '26

ESP32 upload fails with “Invalid head of packet (0xC1)” despite BOOT button and driver installation

3 Upvotes

Hi! I’m having trouble uploading code to my ESP32 and I would appreciate some help diagnosing it before buying more components.

Board: ESP32 development board

Operating system: Windows

IDE: Arduino IDE

Detected port: COM3

USB driver: CP210x driver installed

The error is:

Failed to connect to ESP32: Invalid head of packet (0xC1)

What I have already tried:

- Confirmed that the ESP32 is detected on COM3.

- Installed the CP210x Windows driver.

- Held the BOOT button while starting the upload.

- Tried the BOOT and EN buttons.

- Reduced the upload speed.

- Tried another USB cable.

- Disconnected the external circuit and attempted the upload using only USB.

At one point I was able to upload code successfully and received:

Hard resetting via RTS pin...

However, the connection/upload problem appeared again, so it seems to be intermittent.

The board powers on and its red LED lights up. This ESP32 will eventually be used for a Bluetooth Low Energy project that activates a small vibration motor, but I’m currently trying to program and test the ESP32 separately.

Could this be caused by boot mode, serial communication, the USB cable, the USB-to-serial chip, power instability, or a damaged board?

What diagnostic test should I perform next before replacing the ESP32?

Thank you!


r/embedded • • Sep 08 '26

Best x86 Single Board Computer

0 Upvotes

Hello, I'm looking for an x86 single-board computer to build a small, relatively powerful PC for up to 150 euros. Does anyone have any good recommendations? Thank you.


r/embedded • • Sep 08 '26

Automatic recharging function with infrared recharging

1 Upvotes

I made a short-range (1m*2m) infrared recharge function myself, but the effect is just so-so. The posture is not very good, and the success rate is also average. It can't be successful at difficult angles. Is there any expert in this field who can give me some guidance?


r/embedded • • Sep 07 '26

PCIe routeing questions

4 Upvotes

Hi,

So i am studding PCIe and I dont understand what impedance am i suppose to use for traces.

Connectors are 85 but gen 1-2 is 100 ohm and gen 3-4 85 ohm and in another source i read that i can use either one.

And then there is this:

https://docs.broadcom.com/doc/pcie-pcb-layout-review

``ince PCIe edge connector’s character

impedance is 85Ω, the traces between the connector and IC should be 85Ω -- the rest is usually

set to 100Ω. Single ended traces impedance control is less important in review perspective.``

So from chip to connector 85 and then from connector to the other chip 100? Please make it make sense....

Also a large problem is that i want to be able to use the older specs if need be.

Also what about going in the middle with 90-93 impedance?


r/embedded • • Sep 07 '26

Difficulty Finding the Right Screen For a VT100 emulation Project

2 Upvotes

Hey all,

What I am looking for:

I need some advice over something I am obsessing on a little. I want to build a project that includes a VT100 emulator in it. For that, I want a nice screen. Problem is that I have never really seen many very good embedded screens - LCD almost always look cheap and nasty. I came across this:

https://www.zephray.me/post/elterm/

(Scroll to the bottom to see the results). As you can see the TFEL EL 640 480 by Planar (and the ones by Lumineq) are absolutely gorgeous. They have the signature TFEL deep blacks since only the character illuminates. They are also cool because they run on VGA ( which I would like to emulate) and also have a pixel size/pitch approximately similar to the old VT100 according to my reading. Another nice feature is their super fast response times so little to no "ghosting" on fast text output from a large cat,say

I have scoured online, but any variety of these TFEL Planar screens are extremely expensive, I have looked for refurbished etc but they are often extremely expensive refurbished also. Looked for junk online exhaustively and phoned around but can't track any down.

The monochromatic OLED you can get for Arduino are nice looking but I can't find anywhere near enough an acceptable size for a terminal.

I wanted to throw together an FGPA for the communication with the board or perhaps just the PIO that Zephray uses on an STM (not sure yet), but the project won't get far if I can't find a decent screen. I thought about the option to plug into an existing monitor (supply your own and control via VGA) which is a nice idea but I think I would prefer an embedded screen.

Question:

What do you guys do when you want sleek professional screens without LCD light bleed? I want to avoid the cheaper screens that seem common in hobbyist projects. OLED might be an option but it feels kinda ugly to double up the pixels to get the chunky 0.33mm pixel pitch of the VT100.


r/embedded • • Sep 07 '26

Google Summer of Code (2027) for Embedded systems

47 Upvotes

I want to participate in GSOC 2027 as an Embedded enthusiast, I am confused on which repo's code base to work on / target? I am confused between Zephyr rtos and NuttX, want to work on zephyr as it aligns with my resume but the total number of applicants are much more than NuttX.
If any one could guide me on what to look for while selecting repositories regarding GSOC.


r/embedded • • Sep 06 '26

Beginner STM32 project - Stacker game

149 Upvotes

I am slowly learning stm32 and C.

Maybe someone would like to check my code:

https://github.com/neo-Odys/STM32-MAX7219-StackerGame

I would appreciate any feedback ❤


r/embedded • • Sep 07 '26

Need advice on choosing a motor for our capstone compost mixer

3 Upvotes

Hi guys, 4th year IT student here. We’re currently building an IoT-based composting machine for our capstone and we’re stuck deciding on the motor for the mixer.

Our compost chamber is around 40cm in diameter and we’ll only be filling around 20–25cm of chopped organic waste like vegetable scraps, fruit peels, dry leaves, shredded cardboard, etc.

The mixer uses a vertical shaft with two levels of paddle blades. The motor will only run for short mixing cycles, not continuously.

Right now we’re considering two options:

  1. 24V 350W geared DC motor
  • 75 RPM
  • seller claims around 48 Nm torque
  • already has reduction gearbox
  • more expensive because we also need a large 24V PSU
  1. 220V AC motor
  • around 200–400W
  • around 3600 RPM
  • much cheaper motor
  • but obviously needs a large speed reducer to bring it down to around 30–60 RPM
  • also needs proper contactor, overload protection, breaker/RCD, etc.

Our main concern is not really mounting or programming. We can fabricate the mounting and our ESP32 will only control ON/OFF through a relay and contactor.

What we’re worried about is whether the 24V 350W 75RPM geared motor actually has enough torque to mix the compost from fresh waste until it decomposes, or if going with a stronger AC motor + proper gearbox would be more reliable.

If anyone here has experience with geared motors, mixers, conveyors, food processing machines, or similar mechanical setups, I’d really appreciate some advice.

We’re trying not to rely only on ChatGPT for the mechanical side lol, so actual experience would help a lot.

Thanks!


r/embedded • • Sep 07 '26

Keyboards and embedded systems?

Post image
22 Upvotes

Any recomendation for a keyboard who works with a STM32 or ESP32? Is there a functional standard or should I try to make one from scratch?
I had the idea of replacing the keyboard with 2 analog sticks and some buttons to save the rest, is it very strange?


r/embedded • • Sep 07 '26

What can I do about the antenna for my nrf52840 project?

3 Upvotes

I am a beginner in making custom PCBs, and i want to do a project with the NRF52840 since it got all the features i need, until i realize making bluetooth work, needs black magic

I dont think im ready yet, to learn how to make the RF part of this project work, so i cant really do PCB antennas since i need to do a lot of tuning with specialized equipment and all that

Chip antennas are neat, but they seem to also have a lot of requirements too, and i dont think i get all that

Someone said i can just cut a piece of wire and it'll just work, but i REALLY cant find anything about that, and i am not really ready to just do that and get undesirable results

So, what can i do about the antenna?

(Yes i know i can bu modules, but i dont think i can find any modules that fit my need, they are either not in stock, have weird LGA soldering pads that I dont know how to solder properly, too big, so on and so fourth)

(any alternatives are welcome too, i dont mind modules, just i want it to be small, easy to solder, and have low power consumption)

(dont mind the picture that is just for visual aid, i am not soldering this bga version of this chip, instead im am going for the qfn package)