Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

wireless guitar system based on Raspberry Pi

851 views
Skip to first unread message

wzab

unread,
Oct 18, 2013, 2:32:57 PM10/18/13
to
Hi,

I wanted to refresh my old design of the digital wireless system:
http://www.ise.pw.edu.pl/~wzab/wireless_guitar_system/
To increase range and bandwidth, I wanted to use a WiFi module
(e.g. something from http://www.redpinesignals.com/Modules_&_M2M_systems/Modules/Wi-Fi_Modules/Connect-io-n/index.php ).
However after short comparison of prises and power consumption, I have found,
that Raspberry Pi model A equipped with USB WiFi card may be a very good alternative for microcontroller based solution.
So I have decided to connect CS5343 or CS5344 ADC (http://www.cirrus.com/en/products/cs5343-44.html ) to the port P5 in Raspberry Pi, connect some additional buttons and potentiometers (via I2C equipped ADC) to the GPIO and build a jack ( http://jackaudio.org/netjack ) compatible wireless guitar system.

There is however one question which I need to answer - to allow CS5343/4 ADC to sample sound at 48MHz, I need to provide it with the master clock with frequency of 12.288MHz, 18.432MHz,24.576 MHz or 36.864MHz ( see http://www.cirrus.com/en/pubs/proDatasheet/CS5343_F3.pdf , page 14, table 5).

Of course I can generate this clock with a separate generator, but I think it would more elegant to generate it inside the Raspberry Pi.

I know about possibility to generate such clock with the GPIO MASH dividers
( http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf , section 6.3 General Purpose GPIO Clocks ), but I'm afraid that jitter may significantly impair sound quality.

Is there any better way to generate one of the above mentioned frequencies in another way, without so significant jitter?

TIA & Regards,
Wojtek

wzab

unread,
Oct 20, 2013, 7:34:58 PM10/20/13
to
I can see, that another problem associated with my project, is lack of I2S support in the standard Raspberry Pi kernel - 3.6.11

There is an RPi compatible I2S driver published by Florian Meier in http://blog.koalo.de/2013/05/i2s-support-for-raspberry-pi.html
but it is based on 3.8.xx kernels.
I've tried to integrate it with my Buildroot based environment for Raspberry Pi
(I prefer to use Buildroot generated, initramfs based system, instead of Raspbian to avoid fast wear of the SD card):

1. I downloaded the current Buildroot:
wget wget http://www.buildroot.org/downloads/buildroot-2013.08.1.tar.gz
2. I unpacked it:
tar -xf buildroot-2013.08.1.tar.gz
3. I performed the default configuration for Raspberry Pi:
cd buildroot-2013.08.1; make defconfig rpi_defconfig
4. In the `make menuconfig` I have set "URL of custom Git repository" to git://github.com/koalo/linux.git and "Custom Git version" to "rpi-3.8.yasocdev"

After that, I was able to start `make linux-menuconfig` and select "Device Drivers -> Sound card support -> Advanced Linux Sound Architecture -> ALSA for SoC audio support -> SoC Audio support for the Broadcom BCM2708 I2S module"
(as described in http://blog.koalo.de/2013/05/i2s-support-for-raspberry-pi.html )
I've saved the resulting kernel configuration to the directory in which I've unpacked the buildroot as rpi_kernel_config, and I have made the following changes to "make menuconfig"
1. Set the "Kernel configuration" to "Using a custom config file"
2. Set the "Configuration file path" to "../rpi_kernel_config"
3. I have also set "Port to run a getty (login prompt) on " in "System configuration" to "ttyAMA0"
4. In the "Filesystem images" I have selected:
[*] initial RAM filesystem linked into linux kernel
and
Compression method (lzma)

Then I have compiled the system with "make -j 8"

Finally I've modified the default Buildroot cmdline.txt from "dwc_otg.fiq_fix_enable=1 sdhci-bcm2708.sync_after_dma=0 dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootwait"
to
"dwc_otg.fiq_fix_enable=1 sdhci-bcm2708.sync_after_dma=0 dwc_otg.lpm_enable=0 console=ttyAMA0 root=/dev/mmcblk0p2 rootwait"

(in fact the "root=" and "rootwait" arguments do not make sense, as the whole system starts and runs from initramfs, but it doesn't hurt).

After that the only problem to be solved is generation of the master clock,
and preparation of the codec driver for CS5343/CS5344.

wzab

unread,
Oct 21, 2013, 3:02:26 PM10/21/13
to
To start with something "supposed to work", I have connected the TLV320AIC23B based code ( http://www.propox.com/products/t_204.html?lang=en ), which should be compatible with "mbed" codec.

I have connected:

Codec RPi
3V3 3V3
GND GND
LRCOUT PCM-FS (P5-04)
LRCIN --
BCLK PCM-CLK (P5-03)
SCLK I2C-SCL (P1-05)
SDIN I2C-SDA (P1-03)
MODE GND
MCK --
/CS 3V3
DIN PCM-DOUT (P5-06)
DOUT PCM-DIN (P5-05)
CLKOUT --

After loading of necessary modulea as described in http://blog.koalo.de/2013/05/i2s-support-for-raspberry-pi.html I was able to control mixer.

I have copied a sound file to may Raspberry and tried to play it, but then I got the following errors:
# aplay /tmp/p/ring.wav
[ 441.492406] bcm2708-dmaengine bcm2708-dmaengine: allocating channel for 0
Playing WAVE '/tmp/p/ring.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
[ 441.509527] BUG: scheduling while atomic: aplay/731/0x00000003
[ 441.515366] Modules linked in: snd_soc_rpi_mbed snd_soc_tlv320aic23 bcm2708_dmaengine virt_dma snd_soc_bcm2708_i2s snd_soc_bcm2708 snd_soc_core regmap_spi regmap_i2c snd_compress snd_pcm snd_timer snd snd_page_alloc i2c_bcm2708
[ 441.535752] [<c0013b60>] (unwind_backtrace+0x0/0xf0) from [<c03d59b8>] (__schedule_bug+0x44/0x58)
[ 441.544668] [<c03d59b8>] (__schedule_bug+0x44/0x58) from [<c03d96e8>] (__schedule+0x4d0/0x57c)
[ 441.553316] [<c03d96e8>] (__schedule+0x4d0/0x57c) from [<c03d8270>] (schedule_timeout+0x170/0x200)
[ 441.562310] [<c03d8270>] (schedule_timeout+0x170/0x200) from [<c03d9954>] (wait_for_common+0xcc/0x198)
[ 441.571649] [<c03d9954>] (wait_for_common+0xcc/0x198) from [<c003572c>] (flush_work+0xe4/0x188)
[ 441.580380] [<c003572c>] (flush_work+0xe4/0x188) from [<c0036fb4>] (schedule_on_each_cpu+0x48/0x60)
[ 441.589460] [<c0036fb4>] (schedule_on_each_cpu+0x48/0x60) from [<c00c4108>] (migrate_prep+0x8/0x10)
[ 441.598547] [<c00c4108>] (migrate_prep+0x8/0x10) from [<c009924c>] (alloc_contig_range+0xd8/0x2d0)
[ 441.607526] [<c009924c>] (alloc_contig_range+0xd8/0x2d0) from [<c026d954>] (dma_alloc_from_contiguous+0x6c/0x10c)
[ 441.617844] [<c026d954>] (dma_alloc_from_contiguous+0x6c/0x10c) from [<c0016904>] (__alloc_from_contiguous+0x28/0x74)
[ 441.628493] [<c0016904>] (__alloc_from_contiguous+0x28/0x74) from [<c0016fb0>] (__dma_alloc.isra.20+0x150/0x2c0)
[ 441.638706] [<c0016fb0>] (__dma_alloc.isra.20+0x150/0x2c0) from [<c001724c>] (arm_dma_alloc+0x90/0x98)
[ 441.648022] [<c001724c>] (arm_dma_alloc+0x90/0x98) from [<bf06db9c>] (bcm2708_dma_prep_dma_cyclic+0xf0/0x1b4 [bcm2708_dmaengine])
[ 441.659746] [<bf06db9c>] (bcm2708_dma_prep_dma_cyclic+0xf0/0x1b4 [bcm2708_dmaengine]) from [<bf051c78>] (snd_dmaengine_pcm_trigger+0xd4/0x148 [snd_soc_core])
[ 441.673884] [<bf051c78>] (snd_dmaengine_pcm_trigger+0xd4/0x148 [snd_soc_core]) from [<bf04dd98>] (soc_pcm_trigger+0x64/0x144 [snd_soc_core])
[ 441.686558] [<bf04dd98>] (soc_pcm_trigger+0x64/0x144 [snd_soc_core]) from [<bf024068>] (snd_pcm_do_start+0x2c/0x30 [snd_pcm])
[ 441.697913] [<bf024068>] (snd_pcm_do_start+0x2c/0x30 [snd_pcm]) from [<bf023c48>] (snd_pcm_hw_refine+0x908/0x9bc [snd_pcm])
[ 441.709099] [<bf023c48>] (snd_pcm_hw_refine+0x908/0x9bc [snd_pcm]) from [<bf029dec>] (snd_pcm_lib_read+0x38c/0x40c [snd_pcm])
[ 441.720454] [<bf029dec>] (snd_pcm_lib_read+0x38c/0x40c [snd_pcm]) from [<bf029f18>] (snd_pcm_lib_write+0x50/0x64 [snd_pcm])
[ 441.731632] [<bf029f18>] (snd_pcm_lib_write+0x50/0x64 [snd_pcm]) from [<bf02608c>] (snd_pcm_capture_ioctl+0x1e8/0x4dc [snd_pcm])
[ 441.743248] [<bf02608c>] (snd_pcm_capture_ioctl+0x1e8/0x4dc [snd_pcm]) from [<c00d7864>] (do_vfs_ioctl+0x80/0x5d0)
[ 441.753631] [<c00d7864>] (do_vfs_ioctl+0x80/0x5d0) from [<c00d7dec>] (sys_ioctl+0x38/0x64)
[ 441.761937] [<c00d7dec>] (sys_ioctl+0x38/0x64) from [<c000dbe0>] (ret_fast_syscall+0x0/0x30)
[ 441.775177] BUG: scheduling while atomic: aplay/731/0x00000003
[ 441.781160] Modules linked in: snd_soc_rpi_mbed snd_soc_tlv320aic23 bcm2708_dmaengine virt_dma snd_soc_bcm2708_i2s snd_soc_bcm2708 snd_soc_core regmap_spi regmap_i2c snd_compress snd_pcm snd_timer snd snd_page_alloc i2c_bcm2708
[ 441.801490] [<c0013b60>] (unwind_backtrace+0x0/0xf0) from [<c03d59b8>] (__schedule_bug+0x44/0x58)
[ 441.810413] [<c03d59b8>] (__schedule_bug+0x44/0x58) from [<c03d96e8>] (__schedule+0x4d0/0x57c)
[ 441.819065] [<c03d96e8>] (__schedule+0x4d0/0x57c) from [<c03d8270>] (schedule_timeout+0x170/0x200)
[ 441.828027] [<c03d8270>] (schedule_timeout+0x170/0x200) from [<c03d9954>] (wait_for_common+0xcc/0x198)
[ 441.837366] [<c03d9954>] (wait_for_common+0xcc/0x198) from [<c003572c>] (flush_work+0xe4/0x188)
[ 441.846099] [<c003572c>] (flush_work+0xe4/0x188) from [<c0036fb4>] (schedule_on_each_cpu+0x48/0x60)
[ 441.855188] [<c0036fb4>] (schedule_on_each_cpu+0x48/0x60) from [<c0099364>] (alloc_contig_range+0x1f0/0x2d0)
[ 441.865063] [<c0099364>] (alloc_contig_range+0x1f0/0x2d0) from [<c026d954>] (dma_alloc_from_contiguous+0x6c/0x10c)
[ 441.875457] [<c026d954>] (dma_alloc_from_contiguous+0x6c/0x10c) from [<c0016904>] (__alloc_from_contiguous+0x28/0x74)
[ 441.886101] [<c0016904>] (__alloc_from_contiguous+0x28/0x74) from [<c0016fb0>] (__dma_alloc.isra.20+0x150/0x2c0)
[ 441.896313] [<c0016fb0>] (__dma_alloc.isra.20+0x150/0x2c0) from [<c001724c>] (arm_dma_alloc+0x90/0x98)
[ 441.905659] [<c001724c>] (arm_dma_alloc+0x90/0x98) from [<bf06db9c>] (bcm2708_dma_prep_dma_cyclic+0xf0/0x1b4 [bcm2708_dmaengine])
[ 441.917378] [<bf06db9c>] (bcm2708_dma_prep_dma_cyclic+0xf0/0x1b4 [bcm2708_dmaengine]) from [<bf051c78>] (snd_dmaengine_pcm_trigger+0xd4/0x148 [snd_soc_core])
[ 441.931517] [<bf051c78>] (snd_dmaengine_pcm_trigger+0xd4/0x148 [snd_soc_core]) from [<bf04dd98>] (soc_pcm_trigger+0x64/0x144 [snd_soc_core])
[ 441.944191] [<bf04dd98>] (soc_pcm_trigger+0x64/0x144 [snd_soc_core]) from [<bf024068>] (snd_pcm_do_start+0x2c/0x30 [snd_pcm])
[ 441.955550] [<bf024068>] (snd_pcm_do_start+0x2c/0x30 [snd_pcm]) from [<bf023c48>] (snd_pcm_hw_refine+0x908/0x9bc [snd_pcm])
[ 441.966735] [<bf023c48>] (snd_pcm_hw_refine+0x908/0x9bc [snd_pcm]) from [<bf029dec>] (snd_pcm_lib_read+0x38c/0x40c [snd_pcm])
[ 441.978091] [<bf029dec>] (snd_pcm_lib_read+0x38c/0x40c [snd_pcm]) from [<bf029f18>] (snd_pcm_lib_write+0x50/0x64 [snd_pcm])
[ 441.989272] [<bf029f18>] (snd_pcm_lib_write+0x50/0x64 [snd_pcm]) from [<bf02608c>] (snd_pcm_capture_ioctl+0x1e8/0x4dc [snd_pcm])
[ 442.000887] [<bf02608c>] (snd_pcm_capture_ioctl+0x1e8/0x4dc [snd_pcm]) from [<c00d7864>] (do_vfs_ioctl+0x80/0x5d0)
[ 442.011275] [<c00d7864>] (do_vfs_ioctl+0x80/0x5d0) from [<c00d7dec>] (sys_ioctl+0x38/0x64)
[ 442.019582] [<c00d7dec>] (sys_ioctl+0x38/0x64) from [<c000dbe0>] (ret_fast_syscall+0x0/0x30)
[ 446.032979] bcm2708-dmaengine bcm2708-dmaengine: freeing channel for 0
#

The sound however was played correctly.

wzab

unread,
Oct 22, 2013, 2:05:19 PM10/22/13
to
Hi,

Today I have got recording working as well. It appears that codec is used in the slave mode. Therefore LRCIN must be connected as well.
So the correct connection diagram is:

Codec RPi
3V3 3V3
GND GND
LRCOUT PCM-FS (P5-04)
LRCIN PCM-FS (P5-04) (together with LRCOUT)
BCLK PCM-CLK (P5-03)
SCLK I2C-SCL (P1-05)
SDIN I2C-SDA (P1-03)
MODE GND
MCK --
/CS 3V3
DIN PCM-DOUT (P5-06)
DOUT PCM-DIN (P5-05)
CLKOUT --

However the "scheduling while atomic" problem appears also during recording:
# arecord -D hw:1,0 -f dat /tmp/test1.wav
[ 1179.013561] bcm2708-dmaengine bcm2708-dmaengine: allocating channel for 0
Recording WAVE '/tmp/test1.wav' : Signed 16 bit Little Endian, Rat[ 1179.026691] BUG: scheduling while atomic: arecord/823/0x00000003
e 48000 Hz, Ster[ 1179.033575] Modules linked in:eo
snd_soc_rpi_mbed snd_soc_tlv320aic23 bcm2708_dmaengine virt_dma snd_soc_bcm2708_i2s snd_soc_bcm2708 snd_soc_core regmap_spi regmap_i2c snd_compress i2c_bcm2708 8192cu snd_bcm2835 snd_pcm snd_timer snd snd_page_alloc
[ 1179.057351] [<c0013b60>] (unwind_backtrace+0x0/0xf0) from [<c03d59b8>] (__schedule_bug+0x44/0x58)
[ 1179.066272] [<c03d59b8>] (__schedule_bug+0x44/0x58) from [<c03d96e8>] (__schedule+0x4d0/0x57c)
[ 1179.074926] [<c03d96e8>] (__schedule+0x4d0/0x57c) from [<c03d8270>] (schedule_timeout+0x170/0x200)
[ 1179.083923] [<c03d8270>] (schedule_timeout+0x170/0x200) from [<c03d9954>] (wait_for_common+0xcc/0x198)
[ 1179.093266] [<c03d9954>] (wait_for_common+0xcc/0x198) from [<c003572c>] (flush_work+0xe4/0x188)
[ 1179.102008] [<c003572c>] (flush_work+0xe4/0x188) from [<c0036fb4>] (schedule_on_each_cpu+0x48/0x60)
[ 1179.111091] [<c0036fb4>] (schedule_on_each_cpu+0x48/0x60) from [<c00c4108>] (migrate_prep+0x8/0x10)
[ 1179.120179] [<c00c4108>] (migrate_prep+0x8/0x10) from [<c009924c>] (alloc_contig_range+0xd8/0x2d0)
[ 1179.129190] [<c009924c>] (alloc_contig_range+0xd8/0x2d0) from [<c026d954>] (dma_alloc_from_contiguous+0x6c/0x10c)
[ 1179.139520] [<c026d954>] (dma_alloc_from_contiguous+0x6c/0x10c) from [<c0016904>] (__alloc_from_contiguous+0x28/0x74)
[ 1179.150319] [<c0016904>] (__alloc_from_contiguous+0x28/0x74) from [<c0016fb0>] (__dma_alloc.isra.20+0x150/0x2c0)
[ 1179.160550] [<c0016fb0>] (__dma_alloc.isra.20+0x150/0x2c0) from [<c001724c>] (arm_dma_alloc+0x90/0x98)
[ 1179.169902] [<c001724c>] (arm_dma_alloc+0x90/0x98) from [<bf0f1b9c>] (bcm2708_dma_prep_dma_cyclic+0xf0/0x1b4 [bcm2708_dmaengine])
[ 1179.181628] [<bf0f1b9c>] (bcm2708_dma_prep_dma_cyclic+0xf0/0x1b4 [bcm2708_dmaengine]) from [<bf0d5c78>] (snd_dmaengine_pcm_trigger+0xd4/0x148 [snd_soc_core])
[ 1179.195764] [<bf0d5c78>] (snd_dmaengine_pcm_trigger+0xd4/0x148 [snd_soc_core]) from [<bf0d1d98>] (soc_pcm_trigger+0x64/0x144 [snd_soc_core])
[ 1179.208447] [<bf0d1d98>] (soc_pcm_trigger+0x64/0x144 [snd_soc_core]) from [<bf020068>] (snd_pcm_do_start+0x2c/0x30 [snd_pcm])
[ 1179.219807] [<bf020068>] (snd_pcm_do_start+0x2c/0x30 [snd_pcm]) from [<bf01fc48>] (snd_pcm_hw_refine+0x908/0x9bc [snd_pcm])
[ 1179.230994] [<bf01fc48>] (snd_pcm_hw_refine+0x908/0x9bc [snd_pcm]) from [<bf025950>] (snd_pcm_update_hw_ptr+0x2f4/0x3ac [snd_pcm])
[ 1179.242787] [<bf025950>] (snd_pcm_update_hw_ptr+0x2f4/0x3ac [snd_pcm]) from [<bf025aa8>] (snd_pcm_lib_read+0x48/0x40c [snd_pcm])
[ 1179.254529] [<bf025aa8>] (snd_pcm_lib_read+0x48/0x40c [snd_pcm]) from [<bf021bcc>] (snd_pcm_status+0x1390/0x1668 [snd_pcm])
[ 1179.265734] [<bf021bcc>] (snd_pcm_status+0x1390/0x1668 [snd_pcm]) from [<c00d7864>] (do_vfs_ioctl+0x80/0x5d0)
[ 1179.275692] [<c00d7864>] (do_vfs_ioctl+0x80/0x5d0) from [<c00d7dec>] (sys_ioctl+0x38/0x64)
[ 1179.284000] [<c00d7dec>] (sys_ioctl+0x38/0x64) from [<c000dbe0>] (ret_fast_syscall+0x0/0x30)
[ 1179.297717] BUG: scheduling while atomic: arecord/823/0x40000003
[ 1179.303861] Modules linked in: snd_soc_rpi_mbed snd_soc_tlv320aic23 bcm2708_dmaengine virt_dma snd_soc_bcm2708_i2s snd_soc_bcm2708 snd_soc_core regmap_spi regmap_i2c snd_compress i2c_bcm2708 8192cu snd_bcm2835 snd_pcm snd_timer snd snd_page_alloc
[ 1179.325847] [<c0013b60>] (unwind_backtrace+0x0/0xf0) from [<c03d59b8>] (__schedule_bug+0x44/0x58)
[ 1179.334761] [<c03d59b8>] (__schedule_bug+0x44/0x58) from [<c03d96e8>] (__schedule+0x4d0/0x57c)
[ 1179.343410] [<c03d96e8>] (__schedule+0x4d0/0x57c) from [<c0043f08>] (__cond_resched+0x24/0x34)
[ 1179.352192] [<c0043f08>] (__cond_resched+0x24/0x34) from [<c03d9828>] (_cond_resched+0x3c/0x44)
[ 1179.360960] [<c03d9828>] (_cond_resched+0x3c/0x44) from [<c009f560>] (shrink_page_list+0x48/0x928)
[ 1179.369965] [<c009f560>] (shrink_page_list+0x48/0x928) from [<c009ff50>] (reclaim_clean_pages_from_list+0x110/0x178)
[ 1179.380521] [<c009ff50>] (reclaim_clean_pages_from_list+0x110/0x178) from [<c0099280>] (alloc_contig_range+0x10c/0x2d0)
[ 1179.391360] [<c0099280>] (alloc_contig_range+0x10c/0x2d0) from [<c026d954>] (dma_alloc_from_contiguous+0x6c/0x10c)
[ 1179.401756] [<c026d954>] (dma_alloc_from_contiguous+0x6c/0x10c) from [<c0016904>] (__alloc_from_contiguous+0x28/0x74)
[ 1179.412401] [<c0016904>] (__alloc_from_contiguous+0x28/0x74) from [<c0016fb0>] (__dma_alloc.isra.20+0x150/0x2c0)
[ 1179.422606] [<c0016fb0>] (__dma_alloc.isra.20+0x150/0x2c0) from [<c001724c>] (arm_dma_alloc+0x90/0x98)
[ 1179.431952] [<c001724c>] (arm_dma_alloc+0x90/0x98) from [<bf0f1b9c>] (bcm2708_dma_prep_dma_cyclic+0xf0/0x1b4 [bcm2708_dmaengine])
[ 1179.443677] [<bf0f1b9c>] (bcm2708_dma_prep_dma_cyclic+0xf0/0x1b4 [bcm2708_dmaengine]) from [<bf0d5c78>] (snd_dmaengine_pcm_trigger+0xd4/0x148 [snd_soc_core])
[ 1179.457934] [<bf0d5c78>] (snd_dmaengine_pcm_trigger+0xd4/0x148 [snd_soc_core]) from [<bf0d1d98>] (soc_pcm_trigger+0x64/0x144 [snd_soc_core])
[ 1179.470635] [<bf0d1d98>] (soc_pcm_trigger+0x64/0x144 [snd_soc_core]) from [<bf020068>] (snd_pcm_do_start+0x2c/0x30 [snd_pcm])
[ 1179.481997] [<bf020068>] (snd_pcm_do_start+0x2c/0x30 [snd_pcm]) from [<bf01fc48>] (snd_pcm_hw_refine+0x908/0x9bc [snd_pcm])
[ 1179.493183] [<bf01fc48>] (snd_pcm_hw_refine+0x908/0x9bc [snd_pcm]) from [<bf025950>] (snd_pcm_update_hw_ptr+0x2f4/0x3ac [snd_pcm])
[ 1179.504973] [<bf025950>] (snd_pcm_update_hw_ptr+0x2f4/0x3ac [snd_pcm]) from [<bf025aa8>] (snd_pcm_lib_read+0x48/0x40c [snd_pcm])
[ 1179.516585] [<bf025aa8>] (snd_pcm_lib_read+0x48/0x40c [snd_pcm]) from [<bf021bcc>] (snd_pcm_status+0x1390/0x1668 [snd_pcm])
[ 1179.527770] [<bf021bcc>] (snd_pcm_status+0x1390/0x1668 [snd_pcm]) from [<c00d7864>] (do_vfs_ioctl+0x80/0x5d0)
[ 1179.537721] [<c00d7864>] (do_vfs_ioctl+0x80/0x5d0) from [<c00d7dec>] (sys_ioctl+0x38/0x64)
[ 1179.546028] [<c00d7dec>] (sys_ioctl+0x38/0x64) from [<c000dbe0>] (ret_fast_syscall+0x0/0x30)
[ 1179.554776] BUG: scheduling while atomic: arecord/823/0x00000003
[ 1179.560862] Modules linked in: snd_soc_rpi_mbed snd_soc_tlv320aic23 bcm2708_dmaengine virt_dma snd_soc_bcm2708_i2s snd_soc_bcm2708 snd_soc_core regmap_spi regmap_i2c snd_compress i2c_bcm2708 8192cu snd_bcm2835 snd_pcm snd_timer snd snd_page_alloc
[ 1179.582842] [<c0013b60>] (unwind_backtrace+0x0/0xf0) from [<c03d59b8>] (__schedule_bug+0x44/0x58)
[ 1179.591756] [<c03d59b8>] (__schedule_bug+0x44/0x58) from [<c03d96e8>] (__schedule+0x4d0/0x57c)
[ 1179.600407] [<c03d96e8>] (__schedule+0x4d0/0x57c) from [<c03d8270>] (schedule_timeout+0x170/0x200)
[ 1179.609411] [<c03d8270>] (schedule_timeout+0x170/0x200) from [<c03d9954>] (wait_for_common+0xcc/0x198)
[ 1179.618752] [<c03d9954>] (wait_for_common+0xcc/0x198) from [<c003572c>] (flush_work+0xe4/0x188)
[ 1179.627455] [<c003572c>] (flush_work+0xe4/0x188) from [<c0036fb4>] (schedule_on_each_cpu+0x48/0x60)
[ 1179.636543] [<c0036fb4>] (schedule_on_each_cpu+0x48/0x60) from [<c0099364>] (alloc_contig_range+0x1f0/0x2d0)
[ 1179.646427] [<c0099364>] (alloc_contig_range+0x1f0/0x2d0) from [<c026d954>] (dma_alloc_from_contiguous+0x6c/0x10c)
[ 1179.656951] [<c026d954>] (dma_alloc_from_contiguous+0x6c/0x10c) from [<c0016904>] (__alloc_from_contiguous+0x28/0x74)
[ 1179.667615] [<c0016904>] (__alloc_from_contiguous+0x28/0x74) from [<c0016fb0>] (__dma_alloc.isra.20+0x150/0x2c0)
[ 1179.677825] [<c0016fb0>] (__dma_alloc.isra.20+0x150/0x2c0) from [<c001724c>] (arm_dma_alloc+0x90/0x98)
[ 1179.687173] [<c001724c>] (arm_dma_alloc+0x90/0x98) from [<bf0f1b9c>] (bcm2708_dma_prep_dma_cyclic+0xf0/0x1b4 [bcm2708_dmaengine])
[ 1179.698894] [<bf0f1b9c>] (bcm2708_dma_prep_dma_cyclic+0xf0/0x1b4 [bcm2708_dmaengine]) from [<bf0d5c78>] (snd_dmaengine_pcm_trigger+0xd4/0x148 [snd_soc_core])
[ 1179.713029] [<bf0d5c78>] (snd_dmaengine_pcm_trigger+0xd4/0x148 [snd_soc_core]) from [<bf0d1d98>] (soc_pcm_trigger+0x64/0x144 [snd_soc_core])
[ 1179.725703] [<bf0d1d98>] (soc_pcm_trigger+0x64/0x144 [snd_soc_core]) from [<bf020068>] (snd_pcm_do_start+0x2c/0x30 [snd_pcm])
[ 1179.737064] [<bf020068>] (snd_pcm_do_start+0x2c/0x30 [snd_pcm]) from [<bf01fc48>] (snd_pcm_hw_refine+0x908/0x9bc [snd_pcm])
[ 1179.748254] [<bf01fc48>] (snd_pcm_hw_refine+0x908/0x9bc [snd_pcm]) from [<bf025950>] (snd_pcm_update_hw_ptr+0x2f4/0x3ac [snd_pcm])
[ 1179.760168] [<bf025950>] (snd_pcm_update_hw_ptr+0x2f4/0x3ac [snd_pcm]) from [<bf025aa8>] (snd_pcm_lib_read+0x48/0x40c [snd_pcm])
[ 1179.771802] [<bf025aa8>] (snd_pcm_lib_read+0x48/0x40c [snd_pcm]) from [<bf021bcc>] (snd_pcm_status+0x1390/0x1668 [snd_pcm])
[ 1179.782992] [<bf021bcc>] (snd_pcm_status+0x1390/0x1668 [snd_pcm]) from [<c00d7864>] (do_vfs_ioctl+0x80/0x5d0)
[ 1179.792946] [<c00d7864>] (do_vfs_ioctl+0x80/0x5d0) from [<c00d7dec>] (sys_ioctl+0x38/0x64)
[ 1179.801253] [<c00d7dec>] (sys_ioctl+0x38/0x64) from [<c000dbe0>] (ret_fast_syscall+0x0/0x30)
Aborted by signal Interr[ 1189.701148] bcm2708-dmaengine bcm2708-dmaengine: freeing channel for 0
upt...
#

wzab

unread,
Oct 23, 2013, 7:19:21 PM10/23/13
to
I have successfully implemented drivers handling CS5343 and CS5344 connected to Raspberry Pi in the following way:

CS534x Raspberry Pi
SCLK PCM_CLK (P5-03)
LRCK PCM_FS (P5-04)
SDOUT PCM_DIN (P5-05)

Drivers assume, that the ADC works with MCLK connected to independent 18,432 MHz clock, in Master Single Speed Mode, with clock ratio: 192x/384x/768x MCLK/LRCK
(see http://www.cirrus.com/en/pubs/proDatasheet/CS5343_F3.pdf page 14 for details).
So SDOUT must be pulled up to VCC to select the Master Mode,
LRCK must be left without external pullup or pulldown resistor to select Single Speed Mode, and SCLK must be pulled up to select clock ratio: 192x/384x/768x MCLK/LRCK.

Described setup handles only 2 channel recording with 48000Hz sampling frequency.
I have successfully recorded sound with:
arecord -D hw:1,1 -f S32_LE -c 2 -r 48000 /tmp/test1.wav (for CS5344)
and
arecord -D hw:1,0 -f S32_LE -c 2 -r 48000 /tmp/test2.wav (for CS5343)

The kernel git tree with my additions is available at https://github.com/wzab/linux-rpi-sound

Regards,
Wojtek

wzab

unread,
Oct 24, 2013, 7:02:20 AM10/24/13
to
Hi,
The CS5343/CS5344 support has been included by Florian Meier to his repository: git://github.com/koalo/linux.git , version rpi-3.8.yasocdev , which AFAIK is the main point of work on I2S support for Raspberry Pi.

Regards,
Wojtek

wzab

unread,
Oct 24, 2013, 4:32:48 PM10/24/13
to
To allow transmission of audio from the guitar to the computer running virtual amplifier, I have added jack2 package to the buildroot.

The package definition is as follows:
package/jack2/Config.in :
config BR2_PACKAGE_JACK2
bool "jack2"
select BR2_PACKAGE_LIBSAMPLERATE
select BR2_PACKAGE_LIBSNDFILE
help
jack2 - low latency audio server
http://jackaudio.org/


comment "jack2 - no comments at the moment"

package/jack2/jack2.mk :
################################################################################
#
# jack2
#
################################################################################

JACK2_VERSION = 1.9.9.5
JACK2_SOURCE = jack-$(JACK2_VERSION).tar.bz2
JACK2_SITE = http://jackaudio.org/downloads/
JACK2_LICENSE = LGPLv2.1+
JACK2_LICENSE_FILES = COPYING
JACK2_DEPENDENCIES = \
libsamplerate \
libsndfile

ifneq ($(BR2_PACKAGE_XORG7),y)
define JACK2_WITHOUT_X11
$(SED) "s/check_pkg ('x11')/#check_pkg ('x11')/" $(@D)/wscript
endef
endif

define JACK2_CONFIGURE_CMDS
$(JACK2_WITHOUT_X11)
(cd $(@D); \
$(TARGET_CONFIGURE_OPTS) \
./waf configure \
--prefix=/usr \
--alsa \
)
endef

define JACK2_BUILD_CMDS
(cd $(@D); ./waf build -j $(PARALLEL_JOBS))
endef

define JACK2_INSTALL_TARGET_CMDS
(cd $(@D); ./waf --destdir=$(TARGET_DIR) install)
endef

$(eval $(generic-package))

(above are based on the Midori package)

Jack2 compiles successfully, but when I start it, I get the following error:

# jackd -P41 -p512 -t10000 -dalsa -r48000 -p256 -n2 -Xseq -Chw:1,0
jackdmp 1.9.9.5
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2012 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 41
[ 476.424857] Alignment trap: not handling instruction e1926f9f at [<b6f5e5ec>]
[ 476.432702] Unhandled fault: alignment exception (0x011) at 0xb563008e
Bus error

When I start jack for output via standard bcm2835 alsa driver, I get similar problem:
Bus error
# jackd -P41 -p512 -t10000 -dalsa -r48000 -p256 -n2 -Xseq -Phw:0,0
jackdmp 1.9.9.5
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2012 Grame.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 41
[ 509.241315] Alignment trap: not handling instruction e1926f9f at [<b6f8d5ec>]
[ 509.248457] Unhandled fault: alignment exception (0x011) at 0xb565f08e
Bus error
#

So it seems, that problem is related to jack, not to my driver :-(.

wzab

unread,
Oct 24, 2013, 5:17:47 PM10/24/13
to
According to http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/OT-Problems-with-jackd-on-Linux-tp7592644p7592646.html the problem was known for jack on ARM CPUs.

I had to switch to git version of jack2. I've done it by modification of the
package/jack2/jack2.mk :
################################################################################
#
# jack2
#
################################################################################

JACK2_VERSION = 37976441044d69b91d61d8f6278949a39cf1b7b7
JACK2_SITE = git://github.com/jackaudio/jack2
Now the jack server starts corectly.

wzab

unread,
Nov 17, 2013, 1:08:28 PM11/17/13
to
Further development of this system will be performed in:
https://github.com/wzab/raspberry-pi-guitar-system-v1

Currently I'm waiting for PCB, to continue development
of firmware for ATmega88, used to connect switches and potentiometers
via I2C.

--
Regards,
Wojtek

wzab

unread,
Dec 24, 2013, 6:16:33 PM12/24/13
to
Hi,

It seems, that I have found the problem with "scheduling while atomic bug"

In the function bcm2708_dma_prep_dma_cyclic memory allocations
are done with the GFP_ATOMIC flag or with GFP_KERNEL flag, which may cause the
"scheduling while atomic" problem:

struct dma_async_tx_descriptor *bcm2708_dma_prep_dma_cyclic(
struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
size_t period_len, enum dma_transfer_direction direction,
unsigned long flags, void *context)
{
[...]
/* Now allocate and setup the descriptor. */
d = kzalloc(sizeof(*d) + sizeof(d->sg[0]), GFP_ATOMIC);
[...]
d->control_block_base = dma_alloc_coherent(chan->device->dev,
d->control_block_size, &d->control_block_base_phys, GFP_KERNEL);
[...]
return vchan_tx_prep(&c->vc, &d->vd, DMA_CTRL_ACK | DMA_PREP_INTERRUPT);
}

I don't know if the control_block_size is too big to be allocated with the GFP_ATOMIC flag, or maybe the dma_alloc_coherent on Raspberry Pi doesn't accept this flag?

Does it make sense to change the allocation mode to GFP_ATOMIC there?

Anyway this is the most likely cause of the problem. Unfortunately currently I can't verify it on a real hardware :-(.

Regards,
Wojtek

wzab

unread,
Dec 26, 2013, 5:37:29 PM12/26/13
to
The problem with "scheduling while atomic" has disappeared in a new version of kernel (rpi-3.12.y, probably also in rpi-3.10.y on https://github.com/raspberrypi/linux/ )
The version with added CS5343/CS5344 ADC is available at https://github.com/wzab/linux-rpi-wzab , branch rpi-3.12.y.
I'm sorry but due to github limitations (and probably due to my ignorance ;-) ), I had to remove the https://github.com/wzab/linux-rpi-sound repository to create the new one (there is no way to have two different repositories which are (even indirectly) forked from the same repository).

I have also successfully tested the board https://github.com/wzab/raspberry-pi-guitar-system-v1/tree/master/kicad-project-v1
The atmega88p may be programmed with the avrdude (packaged for buildroot: http://patchwork.ozlabs.org/patch/305060/ ).
The first version of firmware allows to read pins and ADC via I2C. I hope to add it soon to the above repository.

So now the only unsolved problem is the transmission of sound and controls settings from Raspberry Pi to the remote PC (Digital Audio Workstation, running, jack, guitarix, ardour and whatever is needed).
My first trials with running jack + "jack over net" resulted in unacceptably high latency.
My original system (http://www.ise.pw.edu.pl/~wzab/wireless_guitar_system/index.html) used radio link with proprietary protocol, the composite USB Audio+USB MIDI device and "alsa_in", which gave reasonable latency.
What I'm considering now is a similar solution with alsa client running with real time scheduling policy and transferring the data as soon as possible via a low latency network protocol to the alsa_in based program on remote PC.
It would be good if this protocol could combine both audio and controls setting using virtual channels with different priorities.

This thread started to be a kind of blog, which obviously not a purpose of the discussion group, so I definitely move all progress reports and questions to https://github.com/wzab/raspberry-pi-guitar-system-v1/wiki
However I'll watch this thread ans respond to all questions and comments from others.

Regards,
Wojtek
0 new messages