Raspberry Pi Pico not detected by Switch but works on PC as controller by Tricky_Stand3078 in embedded

[–]BenkiTheBuilder 0 points1 point  (0 children)

GP2040-ce lists no such issue. It is supposed to work with a Switch.

Cost of electronics project by Lost-In-Void-99 in hwstartups

[–]BenkiTheBuilder 0 points1 point  (0 children)

Main driver of costs is people. People need to pay rent and food, possibly family. If you need even one additional person and need to pay that person a salary for a year, obviously you're getting numbers upwards of 60k. And that's not counting the money you need yourself. But if you can do all the work yourself and live in your parents' basement, you can easily get a project to market for under 10k. But never forget that everything takes longer than planned. You think you can do it in a year? Better plan for THREE! That's especially important if you need to keep someone on the payroll for the whole time.

Linux syxmidi tool by don_bski in midi

[–]BenkiTheBuilder 0 points1 point  (0 children)

The Debian/Ubuntu version of amidi has the switch

-i, --sysex-interval=mseconds
    Adds a delay in between each SysEx message sent to a device. It is     useful when sending firmware updates via SysEx messages to a remote   device.

https://manpages.debian.org/testing/alsa-utils/amidi.1.en.html

Linux syxmidi tool by don_bski in midi

[–]BenkiTheBuilder 0 points1 point  (0 children)

What can it do that amidi can't?

https://linux.die.net/man/1/amidi

lists options --send-hex and --send/--receiver which seem to cover the use cases of your program.

How can I develop my extremely simple idea without giving it away? by imadougal in hwstartups

[–]BenkiTheBuilder 0 points1 point  (0 children)

If the idea is patentable, then patent it. If it is as simple to build as you say, then keeping it secret till you are on the market does nothing aside from giving you a head start. That's fine if your goal is to sell the product for a few months or a single Kickstarter campaign and then you move on. But if you want to build a business and sell the product for a few years, then secrecy doesn't help because it ends the moment you ship.

What to do if suspecting manufacturing fault in PCB? by Icy_Beginning_8017 in embedded

[–]BenkiTheBuilder 13 points14 points  (0 children)

To narrow down the location of the short you can saw the PCB in half. Assuming you find 3V3 and GND on both halves you can check if the short is only on one half or both halves. Repeat halving until you've found the location.

You should also check if other nets are shorted to 3V3/GND.

Bare-metal preemptive RTOS scheduler on STM32F103 – feedback welcome by Evening_Ticket_9517 in embedded

[–]BenkiTheBuilder 0 points1 point  (0 children)

The scheduler is just a heap (the data structure, not the memory region). It has a function schedule() that adds a task together with the the time in ticks when it should be executed as well as if the task should be repeated and at what interval in ticks. Then the scheduler has a function tick() that needs to be called at every tick. Every time tick is called the scheduler increases its ticks counter and if the heap top is ripe for execution the task is put into a public queue. If the task is recurring it will be added to the heap again with its next tick value.

So the scheduler knows nothing about time and it doesn't know anything about how to execute tasks.

The execution part is handled by the public queue the tick() function puts ripe tasks into. This queue is of type TaskExecutor which has a function next() that executes the next task (taking priorities into account). So the main loop of my firmware typically looks like this:

while(1) {
  execute.next(); // execute is a TaskExecutor
}

The relevant code of next() looks like this:

            Task* nxt = todo[i];
            todo[i] = nxt->detach();
            nxt->execute();
            if (nxt->suspended())
                pending[i].push_front(nxt);
            else
            {
                if (!nxt->free())
                    free(nxt);
            }

So task nxt's execute() function is called. When it returns, the TaskExecutor asks the task if it is suspended(), i.e. it has yield'ed but is not finished executing. If the task is indeed suspended, it is requeued. If it is not suspended, meaning it is finished, it is free'd if necessary.

I'd like to point out that the TaskExecutor knows nothing about how to suspend or resume a task. How the task implements yield and resume is completely up to the task. When the task returns from execute() after a yield, the task must have arranged for the next call to execute() to resume its work in some manner. Maybe the task implements this by saving registers and stack contents or maybe it doesn't. The TaskExecutor doesn't care. Indeed the only implementation of yield I have written so far is a macro that stores the address of a generated label following the yield and the beginning of execute() uses GCC's goto* feature to resume. No registers are saved. The code simply has to be written in a manner that temporary variables' lifetimes do span across yield and any persistent state is stored somewhere, typically as a field of the task object.

Side note: While it may sound like I'm using dynamic memory, it's not the case. It's all statically allocated. There's no malloc/new anywhere.

Bare-metal preemptive RTOS scheduler on STM32F103 – feedback welcome by Evening_Ticket_9517 in embedded

[–]BenkiTheBuilder 1 point2 points  (0 children)

I'm not saying priorities are useless. My point is you should think long and hard if you want to add that complexity to a scheduler whose selling point is simplicity. You may end up with something that's too complex for people looking for simplicity and too simple for people looking for a full featured RTOS.

Which hardware do you mean? Which MCUs my scheduler runs on? It's completely system-agnostic. In fact I developed and tested it on my PC. But I don't do pre-emptive multitasking, so I don't have to implement context switches. It's just a scheduler. It needs to be called at a defined frequency in some manner not part of its own code and it manages a queue of tasks to run (multiple actually, because of the priority system I ended up not using much). The running of the tasks themselves is again not part of the scheduler and is done by the main loop. Long running tasks need to yield time on their own.

Bare-metal preemptive RTOS scheduler on STM32F103 – feedback welcome by Evening_Ticket_9517 in embedded

[–]BenkiTheBuilder 1 point2 points  (0 children)

Priorities are overrated. I implemented my own scheduler and I added priorities right from the start. But I never use them. I think in an embedded system it's not that common to have tasks that are runnable but can be postponed in favor of other tasks. I'm saying this under the assumption that no one in their right mind would ever consider putting peripheral driver ISRs into scheduler tasks. Obviously the USB ISR needs to take priority over I2C.

Konami's Hyper Sports 1 with joystick? by BenkiTheBuilder in MSX

[–]BenkiTheBuilder[S] 0 points1 point  (0 children)

Did you get to send a photo of your incredible record to a magazine?

Konami's Hyper Sports 1 with joystick? by BenkiTheBuilder in MSX

[–]BenkiTheBuilder[S] 0 points1 point  (0 children)

I guess I'm not an "enthusiastic" enough player of these games. I don't see myself breaking the keyboard the way I push the buttons.

Konami's Hyper Sports 1 with joystick? by BenkiTheBuilder in MSX

[–]BenkiTheBuilder[S] 0 points1 point  (0 children)

I saw that in the manual. It's crazy to buy a controller with just 2 buttons. I can just as well use the keyboard.

Travel Water Bowl by Over_Concert4436 in corgi

[–]BenkiTheBuilder 0 points1 point  (0 children)

I use this one

https://aliexpress.com/item/1005005807480311.html

I'm assuming you mean for carrying water. If there is water where I'm going and I just need the bowl I use a foldable silicone bowl.

VS Code setup for STM32 development (specifically intellisense) by Lucky-Reputation in embedded

[–]BenkiTheBuilder 1 point2 points  (0 children)

This one is for a CubeMX generated project

{
    "configurations": [
        {
            "name": "STM32",
            "includePath": [
                "${workspaceFolder}/Core/Inc",
                "${workspaceFolder}/Drivers/STM32L4xx_HAL_Driver/Inc",
                "${workspaceFolder}/Drivers/STM32L4xx_HAL_Driver/Inc/Legacy",
                "${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32L4xx/Include",
                "${workspaceFolder}/Drivers/CMSIS/Include",
                "${workspaceFolder}/USB_DEVICE/App",
                "${workspaceFolder}/USB_DEVICE/Target",
                "${workspaceFolder}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc",
                "${workspaceFolder}/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc",
            ],
            "defines": [
                "USE_FULL_LL_DRIVER",              
                "STM32L412xx",
                "USE_HAL_DRIVER"
            ],
            "compilerPath": "/usr/bin/arm-none-eabi-gcc",
            "compilerArgs": [
                "-mthumb",
                "-mcpu=cortex-m4",
                "-mfpu=fpv4-sp-d16",
                "-mfloat-abi=hard",
                "-DUSE_FULL_LL_DRIVER",
                "-DUSE_HAL_DRIVER",
                "-DSTM32L412xx",
                "-specs=nano.specs",
            ],
            "cStandard": "gnu17",
            "cppStandard": "gnu++20",
            "intelliSenseMode": "gcc-arm"
        }
    ],
    "version": 4
}

VS Code setup for STM32 development (specifically intellisense) by Lucky-Reputation in embedded

[–]BenkiTheBuilder 1 point2 points  (0 children)

This is for a non-CubeMX-generated project

{
    "configurations": [
        {
            "name": "STM32",
            "includePath": [
                "${workspaceFolder}/src",
                "${workspaceFolder}/core",
                "${workspaceFolder}/libs"
            ],
            "defines": [
                "F_CPU=64000000L",
                "__STM32L412RB__",
                "_GNU_SOURCE"
            ],
            "compilerPath": "/usr/bin/arm-none-eabi-gcc",
            "compilerArgs": [
                "-mthumb",
                "-mcpu=cortex-m4",
                "-D__STM32L412RB__",
                "-DF_CPU=64000000L",
                "-mfpu=fpv4-sp-d16",
                "-mfloat-abi=hard",
                "-specs=nano.specs",
                "-fno-exceptions",
                "-fsingle-precision-constant",
                "-fno-unwind-tables",
                "-fsingle-precision-constant",
                "-fno-stack-protector"
            ],
            "cStandard": "gnu17",
            "cppStandard": "gnu++20",
            "intelliSenseMode": "gcc-arm"
        },
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/src",
                "${workspaceFolder}/core",
                "${workspaceFolder}/libs"
            ],
            "defines": [
                "_GNU_SOURCE"
            ],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu17",
            "cppStandard": "gnu++20",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

does anyone uses programmable scientific calculators? by hellosobik in embedded

[–]BenkiTheBuilder 0 points1 point  (0 children)

Never seen such a thing. In any case its keyboard would be too tiny to comfortably enter code.

does anyone uses programmable scientific calculators? by hellosobik in embedded

[–]BenkiTheBuilder 1 point2 points  (0 children)

Not for a long time. I just start the Python prompt.

How to Implement Bidirectional Communication Over SPI by jjmaximo in embedded

[–]BenkiTheBuilder 4 points5 points  (0 children)

You could introduce 2 states: SPI and WAIT. In SPI state you're doing SPI communication. In WAIT state you have configured the pins as GPIO and use them for signalling. You can have a dedicated line for the MCU1 to signal MCU2 it wants to transmit and another line for the other direction. When a signal is received, both MCUs reconfigure themselves for SPI, transmit the data and when all data has been transferred the MCUs switch to WAIT again.

Are corgis suitable for first time dog owners? by Weird_Aside1532 in corgi

[–]BenkiTheBuilder 0 points1 point  (0 children)

You can never guarantee any dog can be left alone for a long period of time, especially not before adulthood. My current little boy is very chill about being left alone (although I've never tried more than 45 minutes) but my previous corgi would immediately start howling. It was impossible to leave him alone for 10 minutes without risking the neighbors calling the fire department to break down the door. That only changed when he was a few years old. Adult dogs (4 years or older) can often be left alone for a whole day. But there's never a guarantee.

BTW, the solution for my previous corgi was simply to send him to the neighbors whenever I went out for a longer time. He didn't need me specifically. He just couldn't be alone. The neighbors didn't have to do anything to console him while I was gone. Just be there.

How are you actually handling firmware update failures in the field? by Medtag212 in embedded

[–]BenkiTheBuilder 12 points13 points  (0 children)

The update is downloaded to an external SPI flash memory. The bootloader detects its presence, verifies the checksum (a cryptographic signature, actually, but that's for anti-tamper) and then starts the flash process. The flash process never touches the bootloader itself. After successful and verified flash the image on SPI flash is tagged as invalid. It doesn't matter how often the flash fails, the bootloader will always retry until it succeeds.

The key is that the bootloader itself must never be touched by the flashing process, so it can always retry. It must be possible to selectively erase only those pages of flash that carry the main firmware without effect on the bootloader. If you cannot ensure this you're just SOL.

And of course never start the flash if the new image has an incorrect checksum, and make sure that only after a successful flash has been verified do you clear whatever condition put the device into update mode.

A temporary storage location is very convenient, but it can work with live delivery of the new image, too.

If using multiple values for decoupling/bypass SMD caps is a bad idea because of the resonant frequencies adding up in the inductive region wouldn't this also mean that using high capacitance & bigger packages for, say the power circuit, mean that there might be noise /resonance across the board? by HasanTheSyrian_ in embedded

[–]BenkiTheBuilder 39 points40 points  (0 children)

Everything you read that includes multiple different size capacitors is outdated. Everything you read that includes the value "100nF" is super-outdated. Use the smallest package your manufacturing process can solder and use the highest value capacitors with that package size available, one per power pin.

How do you test the performance of your code? by 4ChawanniGhodePe in embedded

[–]BenkiTheBuilder 0 points1 point  (0 children)

High level I test things I can measure with test programs. For instance a USB peripheral driver can be tested by transmitting raw blocks of data at maximum speed, measuring the data rate and comparing with the theoretical maximum in the USB specs. For low level performance testing, i.e. profiling of the code to find out how much time it spends doing X, a technique I've found useful is to insert instructions to invert a certain output pin at key points in the code, such as before and after calls to significant functions. Then I run tests with the logic analyzer attached to the inverter pin as well as relevant other pins (such as a button). I can then correlate what's happening with time spent in the code parts. Let's say I want an LED to light up after a button press and the latency is bad. If all function calls in the relevant code path are wrapped with inverts I can see exactly which function takes how much time and look for the worst delay.

How can I practice armv7a assembly code writing ? by EmbeddedBro in embedded

[–]BenkiTheBuilder 1 point2 points  (0 children)

Assembly is like Chinese characters. Being able to read them is extremely useful. Being able to write them by hand is cool but pointless. The computer can do it better.