{"id":34704628,"url":"https://github.com/dinuxbg/beaglemic","last_synced_at":"2025-12-24T23:13:29.943Z","repository":{"id":65799180,"uuid":"232181198","full_name":"dinuxbg/beaglemic","owner":"dinuxbg","description":"Microphone array for PocketBeagle and BeagleBone AI","archived":false,"fork":false,"pushed_at":"2023-11-24T15:26:02.000Z","size":3351,"stargazers_count":14,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-11-24T16:32:32.732Z","etag":null,"topics":["beaglebone","microphone","microphone-array","microphone-audio-capture","pdm","pocketbeagle","pru"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dinuxbg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-01-06T20:37:19.000Z","updated_at":"2023-10-19T15:17:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"449db958-1850-4907-9324-293a667a1177","html_url":"https://github.com/dinuxbg/beaglemic","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"purl":"pkg:github/dinuxbg/beaglemic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinuxbg%2Fbeaglemic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinuxbg%2Fbeaglemic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinuxbg%2Fbeaglemic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinuxbg%2Fbeaglemic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dinuxbg","download_url":"https://codeload.github.com/dinuxbg/beaglemic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinuxbg%2Fbeaglemic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28012096,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["beaglebone","microphone","microphone-array","microphone-audio-capture","pdm","pocketbeagle","pru"],"created_at":"2025-12-24T23:13:14.609Z","updated_at":"2025-12-24T23:13:29.934Z","avatar_url":"https://github.com/dinuxbg.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BeagleMic 16-channel PDM Audio Capture\n\n![](images/cape.jpg)\n\n# Introduction\nEver wanted to record audio from 16 PDM microphones simultanously? Now you can with a BeagleMic running on a [PocketBeagle](https://beagleboard.org/pocket) or [BeagleBone AI](https://bbb.io/ai)\n\nYes, you could opt for the much simpler I2S microphones. But then you won't have fun writing assembly to capture and process sixteen digital signals at more than 2MHz sample rate.\n\nAudio can be routed to BeagleBone's USB gadget driver. Multichannel audio data can be recorded from a regular PC just as you would record from any other USB microphone. See the section about Buildroot image below.\n\nCurrent firmware supports:\n\n| Feature                    | 16 Channel Mode   | 8 Channel Mode    |\n|----------------------------|-------------------|-------------------|\n| PDM Bit Clock              | 2,273 MHz         | 3,448 MHz         |\n| PCM Output Bits Per Sample | 16 bps            | 24 bps            |\n| PCM Output Sample Rate     | 31888 Samples/sec | 26940 Samples/sec |\n\n# Freedom\nTo the best of my knowledge, the entire HW design is Open Hardware and designed with the libre KiCad software. The entire firmware stack is free software, and is built by free toolchains.\n\nPlease report any closed components you notice.\n\n# Hardware\nThe schematic is simple. PDM microphones' digital outputs are connected directly to the PRU input pins. The PRU also drives the bit clock. I have tested on PocketBeagle and BeagleBone AI.\n\n| PocketBeagle | BBAI  | PRU Pin | Type  | Signal               |\n|--------------|-------|---------|-------|----------------------|\n| P2.24        | P9.11 | R30_14  | Output| PDM Bit Clock        |\n| P1.36        | P8.44 | R31_0   | Input | MIC0 and MIC1 Data   |\n| P1.33        | P8.41 | R31_1   | Input | MIC2 and MIC3 Data   |\n| P2.32        | P8.42 | R31_2   | Input | MIC4 and MIC5 Data   |\n| P2.30        | P8.39 | R31_3   | Input | MIC6 and MIC7 Data   |\n| P1.31        | P8.40 | R31_4   | Input | MIC8 and MIC9 Data   |\n| P2.34        | P8.37 | R31_5   | Input | MIC10 and MIC11 Data |\n| P2.28        | P8.38 | R31_6   | Input | MIC12 and MIC13 Data |\n| P1.29        | P8.36 | R31_7   | Input | MIC14 and MIC15 Data |\n\n\nOptionally, high-level software may visualize detected audio direction using a stripe of 16 LEDs hooked to two 74HC595 shift registers:\n\n| PocketBeagle | PB GPIO  | BBAI  | BBAI GPIO | Signal |\n|--------------|----------|-------|-----------|--------|\n| P2.25        | gpio2_9  | P9.30 | gpio5_12  | DS     |\n| P2.29        | gpio1_7  | P9.28 | gpio4_17  | SHCP   |\n| P2.31        | gpio1_19 | P9.23 | gpio7_11  | STCP   |\n\n\nFor each microphone pair, one microphone is configured to output data on the rising clock edge, and the other is configured to output data on the falling edge. This way we need only 8 input GPIOs to capture data from all 16 microphones.\n\nMicrophone breakout board and a PocketBeagle Cape are provided in KiCad format.\n\nUnfortunately the breakout board is essential for a home DIY user like me, since all PDM microphones I could find are BGA. There are numerous youtube guides how to solder BGAs at home using a skillet or a toaster oven.\n\n# Software\n![](images/software-arch-16bit.png)\n\nPRU0 takes care of driving the PDM bit clock and capturing the microphone bit data. It then runs a CIC filter to convert PDM to PCM, and feeds PCM data to PRU1.\n\nPRU0 has two alternative modes of operation. For 16 channels it executes 2 integrator and 2 comb stages for CIC filtering. Whereas for 8 channels it does 3.\n\nPRU1 is retransmitting PCM data from PRU0 down to the ARM host. RPMSG is used for control commands. Shared DDRAM buffers are used for audio data.\n\nHost audio driver presents a standard ALSA audio card, so that arecord and other standard tools can be readily used.\n\n# Running The Example on PocketBeagle\n\n    # Build kernel module\n    sudo apt update\n    sudo apt install build-essential linux-headers-`uname -r`\n    cd driver\n    make\n    # Install kernel module\n    sudo cp beaglemic.ko /lib/modules/`uname -r`/kernel/drivers/rpmsg/\n    sudo depmod -a\n\n    # Load the driver\n    sudo modprobe beaglemic\n\n    # Build PRU firmware\n    cd pru\n    make\n    # Start the new PRU firmware\n    sudo ./start.sh\n\n    # Record audio\n    arecord  -r31888  -c16 -f S16_LE -t wav out.wav\n    arecord  -r26940  -c8 -f S32_LE -t wav out.wav\n    # Hit Ctrl+C to stop.\n\n# Running The Example on BeagleBone AI\n\n    # Prebuilt DTBO for BB AI is provided in this repo. For corresponding\n    # source change, see driver/0001-Initial-BeagleMic-DTS-for-BBAI.patch\n    sudo cp driver/am5729-beagleboneai-beaglemic.dtb /boot/dtbs/`uname -r`/\n    sudo sed -i -e 's@#dtb=@dtb=am5729-beagleboneai-beaglemic.dtb@g' /boot/uEnv.txt\n    sync\n    sudo reboot\n\n    # Build kernel module\n    sudo apt update\n    sudo apt install build-essential linux-headers-`uname -r`\n    cd driver\n    make\n    # Install kernel module\n    sudo cp beaglemic.ko /lib/modules/`uname -r`/kernel/drivers/rpmsg/\n    sudo depmod -a\n\n    # Load the driver\n    sudo modprobe beaglemic\n\n    # Build PRU firmware\n    cd pru\n    make\n    # Start the new PRU firmware\n    sudo ./start-bbai.sh\n\n    # Record audio. Use second audio card, since first one is\n    # the onboard HDMI.\n    arecord -D hw:CARD=BeagleMic -r31888  -c16 -f S16_LE -t wav out.wav\n    arecord -D hw:CARD=BeagleMic -r26940  -c8 -f S32_LE -t wav out.wav\n    # Hit Ctrl+C to stop.\n\n\n# Folder Structure\n\n * beaglemic-cape - Universal cape for BeagleBone AI, PocketBeagle and iCE40HX8K-EVB.\n * driver - Host ALSA audio driver.\n * inmp621-breakout - INMP621 Microphone breakout. Designed to be optionally used with beaglemic-cape.\n * libs - Library code. Currently contains code to drive LED ring for beaglemic-cape.\n * pru - PRU firmware.\n\n# Further Work\nA few ideas to improve the design:\n\n * Move comb filters to PRU1, and try to add more integrators in PRU0.\n * Clean-up the cape PCB.\n   * If possible, leave headers for Class-D output from spare PRUs.\n * Migrate to latest kernel 5.10.\n\n# Buildroot Image With USB UAC2 Gadget Mode\nThe above installation and build instruction steps can be daunting. A [buildroot](https://buildroot.org) configuration for PocketBeagle is available to automate them, and add a bit more.\n\nThe buildroot image is small (about 6MB). It initializes the BeagleMic audio driver, and links it to the UAC2 USB Gadget driver. Your BeagleMic PocketBeagle is presented as USB multichannel microphone, so that a regular PC can capture and run desired audio algorithms.\n\nYou need to download the beaglemic and buildroot.org GIT trees in separate directories. Then, when building from the buildroot directory you need to provide the beaglemic path via BR2_EXTERNAL environment variable. Example commands:\n\n\tgit clone --depth=1 git://git.busybox.net/buildroot\n\tgit clone --depth=1 https://gitlab.com/dinuxbg/beaglemic\n\n\tcd buildroot\n\tgit checkout 2021.05.3  # Last BR release with kernel 4.19\n\texport BR2_EXTERNAL=`realpath ../beaglemic/buildroot/`\n\tmake beaglemic_pb_defconfig\n\tmake -j`nproc`\n\nAbove should result in a small SDCard image which you can flash. Be sure to get the /dev/sdX right for your SD/MMC card reader.\n\n\tsudo dd if=output/images/sdcard.img of=/dev/sdX\n\nWhen PocketBeagle boots and you connect it via USB to your host, you should be able to record:\n\n\tarecord -D hw:CARD=BeagleMic -c8 -t wav -f S32_LE -r24000 out-8ch.wav\n\n## Audio Mode Configuration\nRight now UAC2 Gadget is configured only for 8ch/32bps/24000kHz. With a few manual tweaks in buildroot/package/beaglemic-firmware/beaglemicd it can be switched to 16ch/16bps mode. I'm currently researching how I can make this configuration run-time, and how I can control the LED ring via USB.\n\n# References\n * [CIC Filter Introduction](https://dspguru.com/dsp/tutorials/cic-filter-introduction/)\n * [Another CIC Filter Article](http://www.tsdconseil.fr/log/scriptscilab/cic/cic-en.pdf)\n * [Series of PDM articles and software implementations](https://curiouser.cheshireeng.com/category/projects/pdm-microphone-toys/)\n * [Another CIC Filter Article](https://www.embedded.com/design/configurable-systems/4006446/Understanding-cascaded-integrator-comb-filters)\n * [CIC Filter Introduction](http://home.mit.bme.hu/~kollar/papers/cic.pdf)\n * [SPM0423HD4H Datasheet](http://media.digikey.com/PDF/Data%20Sheets/Knowles%20Acoustics%20PDFs/SPM0423HD4H-WB.pdf)\n * [INMP621 Datasheet](https://invensense.tdk.com/download-pdf/inmp621-datasheet/)\n * [Inspiration for high-bandwidth data acquisition](https://github.com/ZeekHuge/BeagleScope)\n\n# Other Resources\nBelow are various other CIC implementations and PDM microphone boards I've stumbled upon.\n * https://github.com/introlab/16SoundsUSB\n * https://github.com/introlab/odas\n * https://respeaker.io/make_a_smart_speaker/\n * https://github.com/Scrashdown/PRU-Audio-Processing\n * https://github.com/fakufaku/kurodako\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdinuxbg%2Fbeaglemic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdinuxbg%2Fbeaglemic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdinuxbg%2Fbeaglemic/lists"}