Does anyone have experience with a sph0645(i2s microphone) and esp32-s2? - esp32

I am trying with ESP32-S2 WROOM (full name: LilyGO TTGO T8 ESP32-S2 WROOM) to read the input from an i2s microphone(sph0645), and all I get is either silence or a noise (if the assigned pin is not in the microphone fits) so the connection must be correct, I think. I get 1 error message namely E (10715) AUDIO_ELEMENT: [wav] Element already stopped. This error message is nowhere to be found on the espressif forum so I have become a bit hopeless: P also good to know that this is my first post on this topic. So if you know a little more about how to make these two components (i2s microphone and esp32-s2) work, feel free!
To complete the story, this is the complete log.
(64) boot: ESP-IDF v4.2-dirty 2nd stage bootloader
I (64) boot: compile time 15:26:45
I (64) boot: chip revision: 0
I (66) boot.esp32s2: SPI Speed : 80MHz
I (71) boot.esp32s2: SPI Mode : DIO
I (76) boot.esp32s2: SPI Flash Size : 4MB
I (81) boot: Enabling RNG early entropy source...
I (86) boot: Partition Table:
I (90) boot: ## Label Usage Type ST Offset Length
I (97) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (104) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (112) boot: 2 factory factory app 00 00 00010000 00100000
I (119) boot: End of partition table
I (124) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f000020 size=0x0dafc ( 56060) map
I (144) esp_image: segment 1: paddr=0x0001db24 vaddr=0x3ffbf260 size=0x01f70 ( 8048) load
I (147) esp_image: segment 2: paddr=0x0001fa9c vaddr=0x40024000 size=0x00404 ( 1028) load
0x40024000: _WindowOverflow4 at C:/Users/kraan/esp/esp-idf/components/freertos/xtensa/xtensa_vectors.S:1730I (153) esp_image: segment 3: paddr=0x0001fea8 vaddr=0x40024404 size=0x00170 ( 368) load
I (162) esp_image: segment 4: paddr=0x00020020 vaddr=0x40080020 size=0x2a02c (172076) map
0x40080020: _stext at ??:?I (206) esp_image: segment 5: paddr=0x0004a054 vaddr=0x40024574 size=0x0ace4 ( 44260) load
I (225) boot: Loaded app from partition at offset 0x10000
I (225) boot: Disabling RNG early entropy source...
I (225) cache: Instruction cache : size 8KB, 4Ways, cache line size 32Byte
I (233) cpu_start: Pro cpu up.
I (236) cpu_start: Application information:
I (241) cpu_start: Project name: record_wav
I (246) cpu_start: App version: 1
I (251) cpu_start: Compile time: Mar 4 2021 15:26:18
I (257) cpu_start: ELF file SHA256: f689f9b5ef13ab60...
I (263) cpu_start: ESP-IDF: v4.2-dirty
I (268) cpu_start: Single core mode
D (272) memory_layout: Checking 3 reserved memory ranges:
D (278) memory_layout: Reserved memory range 0x3ffb4000 - 0x3ffbf258
D (284) memory_layout: Reserved memory range 0x3ffbf260 - 0x3ffc1a20
D (291) memory_layout: Reserved memory range 0x3ffffa10 - 0x40000000
D (297) memory_layout: Building list of available memory regions:
D (303) memory_layout: Available memory region 0x3ffc1a20 - 0x3ffc4000
D (310) memory_layout: Available memory region 0x3ffc4000 - 0x3ffc8000
D (316) memory_layout: Available memory region 0x3ffc8000 - 0x3ffcc000
D (323) memory_layout: Available memory region 0x3ffcc000 - 0x3ffd0000
D (330) memory_layout: Available memory region 0x3ffd0000 - 0x3ffd4000
D (336) memory_layout: Available memory region 0x3ffd4000 - 0x3ffd8000
D (343) memory_layout: Available memory region 0x3ffd8000 - 0x3ffdc000
D (349) memory_layout: Available memory region 0x3ffdc000 - 0x3ffe0000
D (356) memory_layout: Available memory region 0x3ffe0000 - 0x3ffe4000
D (363) memory_layout: Available memory region 0x3ffe4000 - 0x3ffe8000
D (369) memory_layout: Available memory region 0x3ffe8000 - 0x3ffec000
D (376) memory_layout: Available memory region 0x3ffec000 - 0x3fff0000
D (382) memory_layout: Available memory region 0x3fff0000 - 0x3fff4000
D (389) memory_layout: Available memory region 0x3fff4000 - 0x3fff8000
D (396) memory_layout: Available memory region 0x3fff8000 - 0x3fffc000
D (402) memory_layout: Available memory region 0x3fffc000 - 0x3ffffa10
I (409) heap_init: Initializing. RAM available for dynamic allocation:
D (416) heap_init: New heap initialised at 0x3ffc1a20
I (421) heap_init: At 3FFC1A20 len 0003A5E0 (233 KiB): DRAM
I (427) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM
I (433) cpu_start: Pro cpu start user code
D (491) clk: RTC_SLOW_CLK calibration value: 5765894
D (497) intr_alloc: Connected src 49 to int 2 (cpu 0)
D (497) intr_alloc: Connected src 73 to int 10 (cpu 0)
D (497) intr_alloc: Connected src 28 to int 3 (cpu 0)
D (503) FLASH_HAL: extra_dummy: 0
D (506) spi_flash: trying chip: issi
D (510) spi_flash: trying chip: gd
D (513) spi_flash: trying chip: mxic
D (517) spi_flash: trying chip: generic
I (521) spi_flash: detected chip: generic
I (526) spi_flash: flash io: dio
I (530) cpu_start: Starting scheduler on PRO CPU.
D (535) heap_init: New heap initialised at 0x3fffc000
D (535) intr_alloc: Connected src 17 to int 9 (cpu 0)
I (545) REC_WAV_SDCARD: [ 1 ] Mount sdcard
D (545) intr_alloc: Connected src 23 to int 12 (cpu 0)
D (555) intr_alloc: Connected src 34 to int 13 (cpu 0)
I (605) REC_WAV_SDCARD: [ 2 ] Start codec chip
I (605) REC_WAV_SDCARD: [3.0] Create audio pipeline for recording
I (605) REC_WAV_SDCARD: [3.1] Create fatfs stream to write data to sdcard
I (615) REC_WAV_SDCARD: [3.2] Create i2s stream to read audio data from codec chip
D (625) intr_alloc: Connected src 35 to int 19 (cpu 0)
I (635) REC_WAV_SDCARD: [3.3] Create wav encoder to encode wav format
I (635) REC_WAV_SDCARD: [3.4] Register all elements to audio pipeline
I (645) REC_WAV_SDCARD: [3.5] Link it together [codec_chip]-->i2s_stream-->wav_encoder-->fatfs_stream-->[sdcard]
I (655) REC_WAV_SDCARD: [3.6] Set up uri (file as fatfs_stream, wav as wav encoder)
I (665) REC_WAV_SDCARD: [ 4 ] Set up event listener
I (665) REC_WAV_SDCARD: [4.1] Listening event from pipeline
I (675) REC_WAV_SDCARD: [4.2] Listening event from peripherals
I (685) REC_WAV_SDCARD: [ 5 ] Start audio_pipeline
I (695) REC_WAV_SDCARD: [ 6 ] Listen for all pipeline events, record for 10 Seconds
I (1715) REC_WAV_SDCARD: [ * ] Recording ... 1
I (2715) REC_WAV_SDCARD: [ * ] Recording ... 2
I (3715) REC_WAV_SDCARD: [ * ] Recording ... 3
I (4715) REC_WAV_SDCARD: [ * ] Recording ... 4
I (5715) REC_WAV_SDCARD: [ * ] Recording ... 5
I (6715) REC_WAV_SDCARD: [ * ] Recording ... 6
I (7715) REC_WAV_SDCARD: [ * ] Recording ... 7
I (8715) REC_WAV_SDCARD: [ * ] Recording ... 8
I (9715) REC_WAV_SDCARD: [ * ] Recording ... 9
I (10715) REC_WAV_SDCARD: [ * ] Recording ... 10
I (10715) REC_WAV_SDCARD: [ 7 ] Stop audio_pipeline
W (10715) AUDIO_ELEMENT: IN-[wav] AEL_IO_ABORT
E (10715) AUDIO_ELEMENT: [wav] Element already stopped
W (10725) AUDIO_ELEMENT: IN-[file] AEL_IO_ABORT
W (10735) AUDIO_PIPELINE: There are no listener registered
W (10735) AUDIO_ELEMENT: [file] Element has not create when AUDIO_ELEMENT_TERMINATE
W (10745) AUDIO_ELEMENT: [i2s] Element has not create when AUDIO_ELEMENT_TERMINATE
W (10755) AUDIO_ELEMENT: [wav] Element has not create when AUDIO_ELEMENT_TERMINATE

Related

Always getting “Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.” when trying to use a EPS32 CAM and UART

I’m using micropython to program an ESP32-CAM and send data via UART to another ESP32, but after the loop runs a couple of times, on average 2, at max 4, I get the error below and the camera robots.
This is my code for reference:
import camera
import time
from machine import UART
from machine import Pin
camera.init()
time.sleep(1)
photo = 10
print('initing UART')
time.sleep(1)
uart1 = UART(1, baudrate=9600, tx=2, rx=16)
time.sleep(1)
print('UART started')
x=range(10)
for count in x:
print('taking picture')
try:
photo = camera.capture()
except Exception as e:
print("An exception occurred while capturing the photo:", e)
time.sleep(1)
print("sending picture")
print(len(str(photo)))
try:
uart1.write(bytes(photo[30]))
except Exception as e:
print("An exception occurred while writing to the UART:", e)
print(count)
time.sleep(15)
This is the error:
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400ed39d PS : 0x00060d30 A0 : 0x800e39bb A1 : 0x3ffca5a0
A2 : 0x3f40852c A3 : 0x00000000 A4 : 0x3f951f78 A5 : 0xffffffff
A6 : 0x3f951f40 A7 : 0x3f953753 A8 : 0x800ed330 A9 : 0x3ffca580
A10 : 0x3f950290 A11 : 0x3f407ce0 A12 : 0x3f409cd0 A13 : 0x3f40a220
A14 : 0x3f40a220 A15 : 0x3ffca590 SAR : 0x00000013 EXCCAUSE: 0x0000001c
EXCVADDR: 0xffffffff LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff
ELF file SHA256: 0000000000000000000000000000000000000000000000000000000000000000
Backtrace: 0x400ed39d:0x3ffca5a0 0x400e39b8:0x3ffca640 0x400df811:0x3ffca670 0x400df83e:0x3ffca690 0x400e0307:0x3ffca6b0 0x400ea98d:0x3ffca740 0x400ea9ad:0x3ffca770 0x400e38fe:0x3ffca790 0x400df811:0x3ffca7c0 0x400ece81:0x3ffca7e0 0x400e39b8:0x3ffca880 0x400df811:0x3ffca8f0 0x400df83e:0x3ffca910 0x40101bc4:0x3ffca930 0x40101e0c:0x3ffca9d0 0x400f4200:0x3ffcaa10 0x4008bf6d:0x3ffcaa50
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4948
load:0x40078000,len:9656
load:0x40080400,len:6252
entry 0x400806f4
I (461) psram: This chip is ESP32-D0WD
I (462) spiram: Found 64MBit SPI RAM device
I (462) spiram: SPI RAM mode: flash 40m sram 40m
I (465) spiram: PSRAM initialized, cache is in low/high (2-core) mode.
I (472) cpu_start: Pro cpu up.
I (476) cpu_start: Application information:
I (481) cpu_start: Compile time: Dec 13 2019 08:15:03
I (487) cpu_start: ELF file SHA256: 0000000000000000...
I (493) cpu_start: ESP-IDF: v3.3
I (497) cpu_start: Starting app cpu, entry point is 0x40083830
I (490) cpu_start: App cpu up.
I (1373) spiram: SPI SRAM memory test OK
I (1374) heap_init: Initializing. RAM available for dynamic allocation:
I (1374) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (1380) heap_init: At 3FFBAC10 len 000253F0 (148 KiB): DRAM
I (1386) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (1393) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (1399) heap_init: At 40094998 len 0000B668 (45 KiB): IRAM
I (1406) cpu_start: Pro cpu start user code
I (1411) spiram: Adding pool of 4096K of external SPI memory to heap allocator
I (90) cpu_start: Chip Revision: 1
W (90) cpu_start: Chip revision is higher than the one configured in menuconfig. Suggest to upgrade it.
I (93) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (104) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (134) main: Allocated 2815K for micropython heap at 0x3f940020
MicroPython v1.11-665-gfb0141559-kaki5 on 2019-12-13; ESP32 module (camera) with ESP32
By the way, I have seen some other posts regarding the same issue but all of them the programing is happening in c++ or the solution doesn’t work (or I don’t understand)
I apologize if I’m missing something basic or formatting, it’s my first time posting here. Any help appreciated!

DPC_WATCHDOG_VIOLATION (133/1) Potentially related to NdisFIndicateReceiveNetBufferLists?

We have a NDIS LWF driver, and on a single machine we get a DPC_WATCHDOG_VIOLATION 133/1 bugcheck when they try to connect to their VPN to connect to the internet. This could be related to our NdisFIndicateReceiveNetBufferLists, as the IRQL is raised to DISPATCH before calling it (and obviously lowered to whatever it was afterward), and that does appear in the output of !dpcwatchdog shown below. This is done due to a workaround for another bug explained here:
IRQL_UNEXPECTED_VALUE BSOD after NdisFIndicateReceiveNetBufferLists?
Now this is the bugcheck:
*******************************************************************************
* *
* Bugcheck Analysis *
* *
*******************************************************************************
DPC_WATCHDOG_VIOLATION (133)
The DPC watchdog detected a prolonged run time at an IRQL of DISPATCH_LEVEL
or above.
Arguments:
Arg1: 0000000000000001, The system cumulatively spent an extended period of time at
DISPATCH_LEVEL or above. The offending component can usually be
identified with a stack trace.
Arg2: 0000000000001e00, The watchdog period.
Arg3: fffff805422fb320, cast to nt!DPC_WATCHDOG_GLOBAL_TRIAGE_BLOCK, which contains
additional information regarding the cumulative timeout
Arg4: 0000000000000000
STACK_TEXT:
nt!KeBugCheckEx
nt!KeAccumulateTicks+0x1846b2
nt!KiUpdateRunTime+0x5d
nt!KiUpdateTime+0x4a1
nt!KeClockInterruptNotify+0x2e3
nt!HalpTimerClockInterrupt+0xe2
nt!KiCallInterruptServiceRoutine+0xa5
nt!KiInterruptSubDispatchNoLockNoEtw+0xfa
nt!KiInterruptDispatchNoLockNoEtw+0x37
nt!KxWaitForSpinLockAndAcquire+0x2c
nt!KeAcquireSpinLockAtDpcLevel+0x5c
wanarp!WanNdisReceivePackets+0x4bb
ndis!ndisMIndicateNetBufferListsToOpen+0x141
ndis!ndisMTopReceiveNetBufferLists+0x3f0e4
ndis!ndisCallReceiveHandler+0x61
ndis!ndisInvokeNextReceiveHandler+0x1df
ndis!NdisMIndicateReceiveNetBufferLists+0x104
ndiswan!IndicateRecvPacket+0x596
ndiswan!ApplyQoSAndIndicateRecvPacket+0x20b
ndiswan!ProcessPPPFrame+0x16f
ndiswan!ReceivePPP+0xb3
ndiswan!ProtoCoReceiveNetBufferListChain+0x442
ndis!ndisMCoIndicateReceiveNetBufferListsToNetBufferLists+0xf6
ndis!NdisMCoIndicateReceiveNetBufferLists+0x11
raspptp!CallIndicateReceived+0x210
raspptp!CallProcessRxNBLs+0x199
ndis!ndisDispatchIoWorkItem+0x12
nt!IopProcessWorkItem+0x135
nt!ExpWorkerThread+0x105
nt!PspSystemThreadStartup+0x55
nt!KiStartSystemThread+0x28
SYMBOL_NAME: wanarp!WanNdisReceivePackets+4bb
FOLLOWUP_NAME: MachineOwner
MODULE_NAME: wanarp
IMAGE_NAME: wanarp.sys
And this following is the output of !dpcwatchdog, but I still can't find what is causing this bugcheck, and can't find which function is consuming too much time in DISPATCH level which is causing this bugcheck. Although I think this could be related to some spin locking done by wanarp? Could this be a bug with wanarp? Note that we don't use any spinlocking in our driver, and us raising the IRQL should not cause any issue as it is actually very common for indication in Ndis to be done at IRQL DISPATCH.
So How can I find the root cause of this bugcheck? There are no other third party LWF in the ndis stack.
3: kd> !dpcwatchdog
All durations are in seconds (1 System tick = 15.625000 milliseconds)
Circular Kernel Context Logger history: !logdump 0x2
DPC and ISR stats: !intstats /d
--------------------------------------------------
CPU#0
--------------------------------------------------
Current DPC: No Active DPC
Pending DPCs:
----------------------------------------
CPU Type KDPC Function
dpcs: no pending DPCs found
--------------------------------------------------
CPU#1
--------------------------------------------------
Current DPC: No Active DPC
Pending DPCs:
----------------------------------------
CPU Type KDPC Function
1: Normal : 0xfffff80542220e00 0xfffff805418dbf10 nt!PpmCheckPeriodicStart
1: Normal : 0xfffff80542231d40 0xfffff8054192c730 nt!KiBalanceSetManagerDeferredRoutine
1: Normal : 0xffffbd0146590868 0xfffff80541953200 nt!KiEntropyDpcRoutine
DPC Watchdog Captures Analysis for CPU #1.
DPC Watchdog capture size: 641 stacks.
Number of unique stacks: 1.
No common functions detected!
The captured stacks seem to indicate that only a single DPC or generic function is the culprit.
Try to analyse what other processors were doing at the time of the following reference capture:
CPU #1 DPC Watchdog Reference Stack (#0 of 641) - Time: 16 Min 17 Sec 984.38 mSec
# RetAddr Call Site
00 fffff805418d8991 nt!KiUpdateRunTime+0x5D
01 fffff805418d2803 nt!KiUpdateTime+0x4A1
02 fffff805418db1c2 nt!KeClockInterruptNotify+0x2E3
03 fffff80541808a45 nt!HalpTimerClockInterrupt+0xE2
04 fffff805419fab9a nt!KiCallInterruptServiceRoutine+0xA5
05 fffff805419fb107 nt!KiInterruptSubDispatchNoLockNoEtw+0xFA
06 fffff805418a9a9c nt!KiInterruptDispatchNoLockNoEtw+0x37
07 fffff805418da3cc nt!KxWaitForSpinLockAndAcquire+0x2C
08 fffff8054fa614cb nt!KeAcquireSpinLockAtDpcLevel+0x5C
09 fffff80546ba1eb1 wanarp!WanNdisReceivePackets+0x4BB
0a fffff80546be0b84 ndis!ndisMIndicateNetBufferListsToOpen+0x141
0b fffff80546ba7ef1 ndis!ndisMTopReceiveNetBufferLists+0x3F0E4
0c fffff80546bddfef ndis!ndisCallReceiveHandler+0x61
0d fffff80546ba4a94 ndis!ndisInvokeNextReceiveHandler+0x1DF
0e fffff8057c32d17e ndis!NdisMIndicateReceiveNetBufferLists+0x104
0f fffff8057c30d6c7 ndiswan!IndicateRecvPacket+0x596
10 fffff8057c32d56b ndiswan!ApplyQoSAndIndicateRecvPacket+0x20B
11 fffff8057c32d823 ndiswan!ProcessPPPFrame+0x16F
12 fffff8057c308e62 ndiswan!ReceivePPP+0xB3
13 fffff80546c5c006 ndiswan!ProtoCoReceiveNetBufferListChain+0x442
14 fffff80546c5c2d1 ndis!ndisMCoIndicateReceiveNetBufferListsToNetBufferLists+0xF6
15 fffff8057c2b0064 ndis!NdisMCoIndicateReceiveNetBufferLists+0x11
16 fffff8057c2b06a9 raspptp!CallIndicateReceived+0x210
17 fffff80546bd9dc2 raspptp!CallProcessRxNBLs+0x199
18 fffff80541899645 ndis!ndisDispatchIoWorkItem+0x12
19 fffff80541852b65 nt!IopProcessWorkItem+0x135
1a fffff80541871d25 nt!ExpWorkerThread+0x105
1b fffff80541a00778 nt!PspSystemThreadStartup+0x55
1c ---------------- nt!KiStartSystemThread+0x28
--------------------------------------------------
CPU#2
--------------------------------------------------
Current DPC: No Active DPC
Pending DPCs:
----------------------------------------
CPU Type KDPC Function
2: Normal : 0xffffbd01467f0868 0xfffff80541953200 nt!KiEntropyDpcRoutine
DPC Watchdog Captures Analysis for CPU #2.
DPC Watchdog capture size: 641 stacks.
Number of unique stacks: 1.
No common functions detected!
The captured stacks seem to indicate that only a single DPC or generic function is the culprit.
Try to analyse what other processors were doing at the time of the following reference capture:
CPU #2 DPC Watchdog Reference Stack (#0 of 641) - Time: 16 Min 17 Sec 984.38 mSec
# RetAddr Call Site
00 fffff805418d245a nt!KeClockInterruptNotify+0x453
01 fffff80541808a45 nt!HalpTimerClockIpiRoutine+0x1A
02 fffff805419fab9a nt!KiCallInterruptServiceRoutine+0xA5
03 fffff805419fb107 nt!KiInterruptSubDispatchNoLockNoEtw+0xFA
04 fffff805418a9a9c nt!KiInterruptDispatchNoLockNoEtw+0x37
05 fffff805418a9a68 nt!KxWaitForSpinLockAndAcquire+0x2C
06 fffff8054fa611cb nt!KeAcquireSpinLockRaiseToDpc+0x88
07 fffff80546ba1eb1 wanarp!WanNdisReceivePackets+0x1BB
08 fffff80546be0b84 ndis!ndisMIndicateNetBufferListsToOpen+0x141
09 fffff80546ba7ef1 ndis!ndisMTopReceiveNetBufferLists+0x3F0E4
0a fffff80546bddfef ndis!ndisCallReceiveHandler+0x61
0b fffff80546be3a81 ndis!ndisInvokeNextReceiveHandler+0x1DF
0c fffff80546ba804e ndis!ndisFilterIndicateReceiveNetBufferLists+0x3C611
0d fffff8054e384d77 ndis!NdisFIndicateReceiveNetBufferLists+0x6E
0e fffff8054e3811a9 ourdriver+0x4D70
0f fffff80546ba7d40 ourdriver+0x11A0
10 fffff8054182a6b5 ndis!ndisDummyIrpHandler+0x100
11 fffff80541c164c8 nt!IofCallDriver+0x55
12 fffff80541c162c7 nt!IopSynchronousServiceTail+0x1A8
13 fffff80541c15646 nt!IopXxxControlFile+0xC67
14 fffff80541a0aab5 nt!NtDeviceIoControlFile+0x56
15 ---------------- nt!KiSystemServiceCopyEnd+0x25
--------------------------------------------------
CPU#3
--------------------------------------------------
Current DPC: No Active DPC
Pending DPCs:
----------------------------------------
CPU Type KDPC Function
dpcs: no pending DPCs found
Target machine version: Windows 10 Kernel Version 19041 MP (4 procs)
Also note that we also pass the NDIS_RECEIVE_FLAGS_DISPATCH_LEVEL flag to the NdisFIndicateReceiveNetBufferLists, if the current IRQL is dispatch.
Edit1:
This is also the output of !locks and !qlocks and !ready, And the contention count on one of the resources is 49135, is this normal or too high? Could this be related to our issue? The threads that are waiting on it or own it are for normal processes such as chrome, csrss, etc.
3: kd> !kdexts.locks
**** DUMP OF ALL RESOURCE OBJECTS ****
KD: Scanning for held locks.
Resource # nt!ExpTimeRefreshLock (0xfffff80542219440) Exclusively owned
Contention Count = 17
Threads: ffffcf8ce9dee640-01<*>
KD: Scanning for held locks.....
Resource # 0xffffcf8cde7f59f8 Shared 1 owning threads
Contention Count = 62
Threads: ffffcf8ce84ec080-01<*>
KD: Scanning for held locks...............................................................................................
Resource # 0xffffcf8ce08d0890 Exclusively owned
Contention Count = 49135
NumberOfSharedWaiters = 1
NumberOfExclusiveWaiters = 6
Threads: ffffcf8cf18e3080-01<*> ffffcf8ce3faf080-01
Threads Waiting On Exclusive Access:
ffffcf8ceb6ce080 ffffcf8ce1d20080 ffffcf8ce77f1080 ffffcf8ce92f4080
ffffcf8ce1d1f0c0 ffffcf8ced7c6080
KD: Scanning for held locks.
Resource # 0xffffcf8ce08d0990 Shared 1 owning threads
Threads: ffffcf8cf18e3080-01<*>
KD: Scanning for held locks.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Resource # 0xffffcf8ceff46350 Shared 1 owning threads
Threads: ffffcf8ce6de8080-01<*>
KD: Scanning for held locks......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Resource # 0xffffcf8cf0cade50 Exclusively owned
Contention Count = 3
Threads: ffffcf8ce84ec080-01<*>
KD: Scanning for held locks.........................
Resource # 0xffffcf8cf0f76180 Shared 1 owning threads
Threads: ffffcf8ce83dc080-02<*>
KD: Scanning for held locks.......................................................................................................................................................................................................................................................
Resource # 0xffffcf8cf1875cb0 Shared 1 owning threads
Contention Count = 3
Threads: ffffcf8ce89db040-02<*>
KD: Scanning for held locks.
Resource # 0xffffcf8cf18742d0 Shared 1 owning threads
Threads: ffffcf8cee5e1080-02<*>
KD: Scanning for held locks....................................................................................
Resource # 0xffffcf8cdceeece0 Shared 2 owning threads
Contention Count = 4
Threads: ffffcf8ce3a1c080-01<*> ffffcf8ce5625040-01<*>
Resource # 0xffffcf8cdceeed48 Shared 1 owning threads
Threads: ffffcf8ce5625043-02<*> *** Actual Thread ffffcf8ce5625040
KD: Scanning for held locks...
Resource # 0xffffcf8cf1d377d0 Exclusively owned
Threads: ffffcf8cf0ff3080-02<*>
KD: Scanning for held locks....
Resource # 0xffffcf8cf1807050 Exclusively owned
Threads: ffffcf8ce84ec080-01<*>
KD: Scanning for held locks......
245594 total locks, 13 locks currently held
3: kd> !qlocks
Key: O = Owner, 1-n = Wait order, blank = not owned/waiting, C = Corrupt
Processor Number
Lock Name 0 1 2 3
KE - Unused Spare
MM - Unused Spare
MM - Unused Spare
MM - Unused Spare
CC - Vacb
CC - Master
EX - NonPagedPool
IO - Cancel
CC - Unused Spare
IO - Vpb
IO - Database
IO - Completion
NTFS - Struct
AFD - WorkQueue
CC - Bcb
MM - NonPagedPool
3: kd> !ready
KSHARED_READY_QUEUE fffff8053f1ada00: (00) ****------------------------------------------------------------
SharedReadyQueue fffff8053f1ada00: No threads in READY state
Processor 0: No threads in READY state
Processor 1: Ready Threads at priority 15
THREAD ffffcf8ce9dee640 Cid 2054.2100 Teb: 000000fab7bca000 Win32Thread: 0000000000000000 READY on processor 1
Processor 2: No threads in READY state
Processor 3: No threads in READY state
3: kd> dt nt!_ERESOURCE 0xffffcf8ce08d0890
+0x000 SystemResourcesList : _LIST_ENTRY [ 0xffffcf8c`e08d0610 - 0xffffcf8c`e08cf710 ]
+0x010 OwnerTable : 0xffffcf8c`ee6e8210 _OWNER_ENTRY
+0x018 ActiveCount : 0n1
+0x01a Flag : 0xf86
+0x01a ReservedLowFlags : 0x86 ''
+0x01b WaiterPriority : 0xf ''
+0x020 SharedWaiters : 0xffffae09`adcae8e0 Void
+0x028 ExclusiveWaiters : 0xffffae09`a9aabea0 Void
+0x030 OwnerEntry : _OWNER_ENTRY
+0x040 ActiveEntries : 1
+0x044 ContentionCount : 0xbfef
+0x048 NumberOfSharedWaiters : 1
+0x04c NumberOfExclusiveWaiters : 6
+0x050 Reserved2 : (null)
+0x058 Address : (null)
+0x058 CreatorBackTraceIndex : 0
+0x060 SpinLock : 0
3: kd> dx -id 0,0,ffffcf8cdcc92040 -r1 (*((ntkrnlmp!_OWNER_ENTRY *)0xffffcf8ce08d08c0))
(*((ntkrnlmp!_OWNER_ENTRY *)0xffffcf8ce08d08c0)) [Type: _OWNER_ENTRY]
[+0x000] OwnerThread : 0xffffcf8cf18e3080 [Type: unsigned __int64]
[+0x008 ( 0: 0)] IoPriorityBoosted : 0x0 [Type: unsigned long]
[+0x008 ( 1: 1)] OwnerReferenced : 0x0 [Type: unsigned long]
[+0x008 ( 2: 2)] IoQoSPriorityBoosted : 0x1 [Type: unsigned long]
[+0x008 (31: 3)] OwnerCount : 0x1 [Type: unsigned long]
[+0x008] TableSize : 0xc [Type: unsigned long]
3: kd> dx -id 0,0,ffffcf8cdcc92040 -r1 ((ntkrnlmp!_OWNER_ENTRY *)0xffffcf8cee6e8210)
((ntkrnlmp!_OWNER_ENTRY *)0xffffcf8cee6e8210) : 0xffffcf8cee6e8210 [Type: _OWNER_ENTRY *]
[+0x000] OwnerThread : 0x0 [Type: unsigned __int64]
[+0x008 ( 0: 0)] IoPriorityBoosted : 0x1 [Type: unsigned long]
[+0x008 ( 1: 1)] OwnerReferenced : 0x1 [Type: unsigned long]
[+0x008 ( 2: 2)] IoQoSPriorityBoosted : 0x1 [Type: unsigned long]
[+0x008 (31: 3)] OwnerCount : 0x0 [Type: unsigned long]
[+0x008] TableSize : 0x7 [Type: unsigned long]
Thanks for reporting this. I've tracked this down to an OS bug: there's a deadlock in wanarp. This issue appears to affect every version of the OS going back to Windows Vista.
I've filed internal issue task.ms/42393356 to track this: if you have a Microsoft support contract, your rep can get you status updates on that issue.
Meanwhile, you can partially work around this issue by either:
Indicating 1 packet at a time (NumberOfNetBufferLists==1); or
Indicating on a single CPU at a time
The bug in wanarp is exposed when 2 or more CPUs collectively process 3 or more NBLs at the same time. So either workaround would avoid the trigger conditions.
Depending on how much bandwidth you're pushing through this network interface, those options could be rather bad for CPU/battery/throughput. So please try to avoid pessimizing batching unless it's really necessary. (For example, you could make this an option that's off-by-default, unless the customer specifically uses wanarp.)
Note that you cannot fully prevent the issue yourself. Other drivers in the stack, including NDIS itself, have the right to group packets together, which would have the side effect re-batching the packets that you carefully un-batched. However, I believe that you can make a statistically significant dent in the crashes if you just indicate 1 NBL at a time, or indicate multiple NBLs on 1 CPU at a time.
Sorry this is happening to you again! wanarp is... a very old codebase.

SPIDEV Linux Driver on Intel Atom E3900 Series [duplicate]

This question already has answers here:
spidev Linux driver on Intel Atom board
(3 answers)
Closed 3 years ago.
I am attempting to expose the SPI #2 interface from the Intel E3900 series (specifically the E3940) as a spidev interface to CentOS 8 (kernel version 4.18). As a fallback, any method to access the SPI controller through a C/C++ API would be acceptable.
I am trying to determine if the issue is something that must be corrected by the BIOS vendor or something I can fix with an ACPI patch. The vendor (Congatec) has claimed that the SPI interface is currently not supported as a userspace entity, but I am still waiting for my issue to be escalated to their engineering group to confirm that. The vendor also stated that the BIOS setting for the SPIs should be left at "Disabled", but I have also tried the "PCI" and "ACPI" options with no change.
I have attempted to merge together snippets from several references to create an ACPI patch, including:
spidev Linux driver on Intel Atom board
https://www.kernel.org/doc/Documentation/acpi/initrd_table_override.txt
https://www.kernel.org/doc/html/latest/firmware-guide/acpi/enumeration.html
I have recompiled the CentOS 8 kernel to include all the necessary options, and I am able to successfully rebuild the Linux initrd (initramfs in CentOS 8). I confirmed through dmesg logs that my modification is being loaded at boot; I don't see any error messages in the logs, so I am assuming that it is being applied successfully.
For reference, here are the kernel options I have ensured are compiled in (=y). I plan to eventually use kernel modules in concert with the stock kernel, but for now I thought this was the easier path.
CONFIG_MFD_INTEL_LPSS
CONFIG_MFD_INTEL_LPSS_ACPI
CONFIG_MFD_INTEL_LPSS_PCI
CONFIG_X86_INTEL_LPSS
CONFIG_SERIAL_8250_LPSS
CONFIG_PWM_LPSS
CONFIG_PWM_LPSS_PCI
CONFIG_PWM_LPSS_PLATFORM
CONFIG_SPI_PXA2XX
CONFIG_SPI_SPIDEV
CONFIG_SPI_BITBANG
When I dump the unmodified ACPI device tree with the following commands, I am able to see references to three different SPI buses, which correlate with their BIOS settings. As far as I know, the Intel chip only includes two SPI buses, which makes me think this really is something that will need to be fixed in their BIOS.
acpidump >acpidump
acpixtract -a acpidump
iasl -sa *.dat
grep -i spi *.dsl
I have tried several options to patch the device tree that include both references I found and reusing the device-tree configuration from SPI#1 (which I am assuming works), but none have seemed to work. Since the examples I have found are from the E3800 series, I'm hoping that I just have some register setting or pin identifier wrong and it needs to be updated for the E3900 series.
For reference, the SPI#1 bus is used to control other components on the SOM, so I want to avoid using that for general purpose as well.
Thanks in advance for any ideas/support.
DefinitionBlock ("spidev.aml", "SSDT", 2, "INTEL ", "SpiDev", 1)
{
External (_SB_.PCI0.SPI2, DeviceObj)
Scope (\_SB.PCI0.SPI2)
{
Device (FPNT)
{
Method (_HID, 0, NotSerialized) // _HID: Hardware ID
{
Return ("FPNT_DIS")
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
Return (0x0F)
}
Method (_CRS, 0, Serialized) // _CRS: Current Resource Settings
{
Name (BBUF, ResourceTemplate ()
{
SpiSerialBusV2 (0x0000, PolarityLow, FourWireMode, 0x08,
ControllerInitiated, 0x002DC6C0, ClockPolarityLow,
ClockPhaseFirst, "\\_SB.PCI0.SPI2",
0x00, ResourceConsumer, , Exclusive,
)
GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
"\\_SB.GPO1", 0x00, ResourceConsumer, ,
)
{ // Pin list
0x0043
}
GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullDefault, 0x0000,
"\\_SB.GPO0", 0x00, ResourceConsumer, ,
)
{ // Pin list
0x000E
}
})
Return (BBUF) /* \_SB_.PCI0.SPI2.FPNT._CRS.BBUF */
}
}
}
}
DefinitionBlock ("spidev.aml", "SSDT", 5, "INTEL", "SPIDEV", 1)
{
External (_SB_.PCI0.SPI2, DeviceObj)
Scope (\_SB.PCI0.SPI2)
{
Device (TP0) {
Name (_HID, "SPT0001")
Name (_DDN, "SPI test device connected to CS2")
Name (_DSD, Package() {
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package () {
Package (2) { "compatible", "spidev" },
}
})
Name (_CRS, ResourceTemplate () {
SpiSerialBus (
2, // Chip select
PolarityLow, // Chip select is active low
FourWireMode, // Full duplex
8, // Bits per word is 8 (byte)
ControllerInitiated, // Don't care
1000000, // 1 MHz
ClockPolarityLow, // SPI mode 0
ClockPhaseFirst, // SPI mode 0
"\\_SB.PCI0.SPI2", // SPI host controller
0 // Must be 0
)
})
}
}
}
DefinitionBlock ("spidev.aml", "SSDT", 5, "INTEL", "SPIDEV", 1)
{
External (_SB_.PCI0.SPI2, DeviceObj)
Scope (\_SB.PCI0.SPI2)
{
Device (TP0) {
Name (_HID, "SPT0001")
Name (_DDN, "SPI test device connected to CS2")
Name (_CRS, ResourceTemplate () {
SpiSerialBus (
2, // Chip select
PolarityLow, // Chip select is active low
FourWireMode, // Full duplex
8, // Bits per word is 8 (byte)
ControllerInitiated, // Don't care
1000000, // 1 MHz
ClockPolarityLow, // SPI mode 0
ClockPhaseFirst, // SPI mode 0
"\\_SB.PCI0.SPI2", // SPI host controller
0 // Must be 0
)
})
}
}
}
EDIT: Added dmesg output after applying above via initrd
[ 0.000000] BRK [0x63ef9000, 0x63ef9fff] PGTABLE
[ 0.000000] BRK [0x63efa000, 0x63efafff] PGTABLE
[ 0.000000] RAMDISK: [mem 0x3b4f6000-0x3ce5cfff]
[ 0.000000] ACPI: SSDT ACPI table found in initrd [kernel/firmware/acpi/spidev.aml][0xb7]
[ 0.000000] modified physical RAM map:
[ 0.000000] modified: [mem 0x0000000000000000-0x0000000000000fff] reserved
[ 0.000000] modified: [mem 0x0000000000001000-0x000000000003efff] usable
--
[ 0.000000] ACPI: UEFI 0x00000000798C8400 000042 (v01 ALASKA A M I 00000000 00000000)
[ 0.000000] ACPI: TPM2 0x00000000798C8450 000034 (v04 ALASKA A M I 00000001 AMI 00000000)
[ 0.000000] ACPI: WDAT 0x00000000798C8490 000104 (v01 00000000 00000000)
[ 0.000000] ACPI: Table Upgrade: install [SSDT- INTEL- SPIDEV]
[ 0.000000] ACPI: SSDT 0x00000000774A2000 0000B7 (v05 INTEL SPIDEV 00000001 INTL 20180629)
[ 0.000000] ACPI: Local APIC address 0xfee00000
[ 0.000000] No NUMA configuration found
[ 0.000000] Faking a node at [mem 0x0000000000000000-0x000000017fffffff]
--
[ 1.141553] dw-apb-uart.0: ttyS4 at MMIO 0x91326000 (irq = 4, base_baud = 115200) is a 16550A
[ 1.144263] dw-apb-uart.1: ttyS5 at MMIO 0x91324000 (irq = 5, base_baud = 115200) is a 16550A
[ 1.146886] dw-apb-uart.2: ttyS6 at MMIO 0x91322000 (irq = 6, base_baud = 115200) is a 16550A
[ 1.149799] pxa2xx-spi pxa2xx-spi.4: cs2 >= max 2
[ 1.151063] spi_master spi2: failed to add SPI device SPT0001:00 from ACPI
[ 1.153366] rdac: device handler registered
[ 1.154791] hp_sw: device handler registered
[ 1.156043] emc: device handler registered
[root#localhost ~]# ls /dev/
autofs fuse log nvram tty tty25 tty42 tty6 ttyS5 vcsa1
block gpiochip0 loop-control port tty0 tty26 tty43 tty60 ttyS6 vcsa2
bus gpiochip1 mapper ppp tty1 tty27 tty44 tty61 ttyS7 vcsa3
char gpiochip2 mcelog pps0 tty10 tty28 tty45 tty62 ttyS8 vcsa4
console gpiochip3 mei0 pps1 tty11 tty29 tty46 tty63 ttyS9 vcsa5
core hidraw0 mem ptmx tty12 tty3 tty47 tty7 uhid vcsa6
cpu hpet memory_bandwidth ptp0 tty13 tty30 tty48 tty8 uinput vfio
cpu_dma_latency hugepages mmcblk1 ptp1 tty14 tty31 tty49 tty9 urandom vga_arbiter
cs hwrng mmcblk1boot0 pts tty15 tty32 tty5 ttyS0 usbmon0 vhci
cuse i2c-0 mmcblk1boot1 random tty16 tty33 tty50 ttyS1 usbmon1 vhost-net
disk i2c-1 mmcblk1p1 raw tty17 tty34 tty51 ttyS10 usbmon2 vhost-vsock
dm-0 i2c-2 mmcblk1p2 rtc tty18 tty35 tty52 ttyS11 vcs zero
dm-1 i2c-3 mmcblk1p3 rtc0 tty19 tty36 tty53 ttyS12 vcs1
dri i2c-4 mmcblk1rpmb shm tty2 tty37 tty54 ttyS13 vcs2
drm_dp_aux0 i2c-5 mqueue snapshot tty20 tty38 tty55 ttyS14 vcs3
drm_dp_aux1 initctl net snd tty21 tty39 tty56 ttyS15 vcs4
fb0 input network_latency stderr tty22 tty4 tty57 ttyS2 vcs5
fd kmsg network_throughput stdin tty23 tty40 tty58 ttyS3 vcs6
full kvm null stdout tty24 tty41 tty59 ttyS4 vcsa
EDIT: Added requested tables.dat output
https://pastebin.com/TBj8LRVc
EDIT: Added requested status output
[root#localhost ~]# grep -H 15 /sys/bus/acpi/devices/*/status
/sys/bus/acpi/devices/device:19/status:15
/sys/bus/acpi/devices/device:1a/status:15
/sys/bus/acpi/devices/device:1d/status:15
/sys/bus/acpi/devices/device:3e/status:15
/sys/bus/acpi/devices/device:44/status:15
/sys/bus/acpi/devices/device:45/status:15
/sys/bus/acpi/devices/INT33A1:00/status:15
/sys/bus/acpi/devices/INT3452:00/status:15
/sys/bus/acpi/devices/INT3452:01/status:15
/sys/bus/acpi/devices/INT3452:02/status:15
/sys/bus/acpi/devices/INT3452:03/status:15
/sys/bus/acpi/devices/INT3511:00/status:15
/sys/bus/acpi/devices/INT3512:00/status:15
/sys/bus/acpi/devices/LNXPOWER:00/status:15
/sys/bus/acpi/devices/MSFT0101:00/status:15
/sys/bus/acpi/devices/PNP0103:00/status:15
/sys/bus/acpi/devices/PNP0C0D:00/status:15
/sys/bus/acpi/devices/PNP0C0E:00/status:15
EDIT: Added requested lspci output
[root#localhost ~]# lspci -nk -s 19
00:19.0 1180: 8086:5ac2 (rev 0b)
Subsystem: 8086:7270
Kernel driver in use: intel-lpss
00:19.1 1180: 8086:5ac4 (rev 0b)
Subsystem: 8086:7270
Kernel driver in use: intel-lpss
00:19.2 1180: 8086:5ac6 (rev 0b)
Subsystem: 8086:7270
Kernel driver in use: intel-lpss
Thanks to 0andriy! He got me past the roadblock and taught me a few new commands along the way. The root cause of my issue was two-fold as it turned out:
The board vendor had cautioned me against enabling SPI#1 in BIOS, as that bus is used to control items on the SoM itself (assuming via their Linux BSP/driver?). I had to enable all three SPI interfaces in ACPI mode to have them be loaded and show up in the lspci -nk -s 19 output.
The device-tree update file had an error, which I missed previously because the interface itself was not being loaded. The AML file needed to specify Chip Select 1, not 2.
The script below will make all of the initrd changes and expose all three SPI buses using SPIDEV. On the board I am testing with, the SPI bus is coming through as spidev1.
I still need to confirm the Maximum speed the E3900 can handle, but I think the other parameters are set correctly.
#!/bin/bash
#
# SCRIPT NAME: ENABLE SPIDEV ON INTEL ATOM E3900 SERIES SOC
# TARGET PLATFORM: CENTOS8_x86-64
# AUTHOR: ADAM ACKERMAN
# LICENSE: MIT
#
# REFERENCES:
# https://www.kernel.org/doc/Documentation/acpi/initrd_table_override.txt
# https://stackoverflow.com/questions/39118721/spidev-linux-driver-on-intel-atom-board
# https://www.kernel.org/doc/html/latest/firmware-guide/acpi/enumeration.html
#
# Pull current kernel version
KERNEL_VER=$(cat /proc/version | cut -d " " -f 3)
# Verify current kernel includes spidev support
# NOTE: If configured as module, must be actively loaded
if [[ ! -d /sys/class/spidev ]]; then
modprobe spidev
if [[ ! -d /sys/class/spidev ]]; then
echo "Kernel does not support SPIDEV. Please enable first."
exit 1
fi
fi
# Move the backup file back to active, if exists
if [[ -f /boot/initramfs-$KERNEL_VER.img.bak ]]; then
rm -f /boot/initramfs-$KERNEL_VER.img
mv /boot/initramfs-$KERNEL_VER.img.bak /boot/initramfs-$KERNEL_VER.img
fi
# Create new temp directory and change to it
ACPI_TMP=$(mktemp -d)
cd $ACPI_TMP
# Reference commands to pull current ACPI tree
#acpidump >acpidump
#acpixtract -a acpidump
#iasl -sa *.dat
#grep -i spi *.dsl
# Paste in ASL file to enable the SPIDEV interface
cat > spidev.asl <<'_EOF'
DefinitionBlock ("spidev.aml", "SSDT", 5, "INTEL", "SPIDEV", 1)
{
External (_SB_.PCI0.SPI1, DeviceObj)
Scope (\_SB.PCI0.SPI1)
{
Device (TP10) {
Name (_HID, "SPT0001")
Name (_DDN, "SPI1-CS0")
Name (_CRS, ResourceTemplate () {
SpiSerialBus (
0, // Chip select
PolarityLow, // Chip select is active low
FourWireMode, // Full duplex
8, // Bits per word is 8 (byte)
ControllerInitiated, // Don't care
1000000, // 1 MHz
ClockPolarityLow, // SPI mode 0
ClockPhaseFirst, // SPI mode 0
"\\_SB.PCI0.SPI1", // SPI host controller
0 // Must be 0
)
})
}
Device (TP11) {
Name (_HID, "SPT0001")
Name (_DDN, "SPI1-CS1")
Name (_CRS, ResourceTemplate () {
SpiSerialBus (
1, // Chip select
PolarityLow, // Chip select is active low
FourWireMode, // Full duplex
8, // Bits per word is 8 (byte)
ControllerInitiated, // Don't care
1000000, // 1 MHz
ClockPolarityLow, // SPI mode 0
ClockPhaseFirst, // SPI mode 0
"\\_SB.PCI0.SPI1", // SPI host controller
0 // Must be 0
)
})
}
}
External (_SB_.PCI0.SPI2, DeviceObj)
Scope (\_SB.PCI0.SPI2)
{
Device (TP20) {
Name (_HID, "SPT0001")
Name (_DDN, "SPI2-CS0")
Name (_CRS, ResourceTemplate () {
SpiSerialBus (
0, // Chip select
PolarityLow, // Chip select is active low
FourWireMode, // Full duplex
8, // Bits per word is 8 (byte)
ControllerInitiated, // Don't care
1000000, // 1 MHz
ClockPolarityLow, // SPI mode 0
ClockPhaseFirst, // SPI mode 0
"\\_SB.PCI0.SPI2", // SPI host controller
0 // Must be 0
)
})
}
Device (TP21) {
Name (_HID, "SPT0001")
Name (_DDN, "SPI2-CS1")
Name (_CRS, ResourceTemplate () {
SpiSerialBus (
1, // Chip select
PolarityLow, // Chip select is active low
FourWireMode, // Full duplex
8, // Bits per word is 8 (byte)
ControllerInitiated, // Don't care
1000000, // 1 MHz
ClockPolarityLow, // SPI mode 0
ClockPhaseFirst, // SPI mode 0
"\\_SB.PCI0.SPI2", // SPI host controller
0 // Must be 0
)
})
}
}
External (_SB_.PCI0.SPI3, DeviceObj)
Scope (\_SB.PCI0.SPI3)
{
Device (TP30) {
Name (_HID, "SPT0001")
Name (_DDN, "SPI3-CS0")
Name (_CRS, ResourceTemplate () {
SpiSerialBus (
0, // Chip select
PolarityLow, // Chip select is active low
FourWireMode, // Full duplex
8, // Bits per word is 8 (byte)
ControllerInitiated, // Don't care
1000000, // 1 MHz
ClockPolarityLow, // SPI mode 0
ClockPhaseFirst, // SPI mode 0
"\\_SB.PCI0.SPI3", // SPI host controller
0 // Must be 0
)
})
}
Device (TP31) {
Name (_HID, "SPT0001")
Name (_DDN, "SPI3-CS1")
Name (_CRS, ResourceTemplate () {
SpiSerialBus (
1, // Chip select
PolarityLow, // Chip select is active low
FourWireMode, // Full duplex
8, // Bits per word is 8 (byte)
ControllerInitiated, // Don't care
1000000, // 1 MHz
ClockPolarityLow, // SPI mode 0
ClockPhaseFirst, // SPI mode 0
"\\_SB.PCI0.SPI3", // SPI host controller
0 // Must be 0
)
})
}
}
}
_EOF
# Convert the ASL file to AML
iasl spidev.asl
# Create new directory structure to match initrd format
mkdir -p kernel/firmware/acpi
# Copy in the AML file
cp spidev.aml kernel/firmware/acpi
# Load all files into a new initrd in /boot
find kernel | cpio -H newc --create > /boot/instrumented_initrd
# Move out of the temporary directory and remove
cd ~
rm -rf $ACPI_TMP
# Merge the current initrd to the end of the one just created
cat /boot/initramfs-$KERNEL_VER.img >>/boot/instrumented_initrd
# Move the working one to a backup location
mv /boot/initramfs-$KERNEL_VER.img /boot/initramfs-$KERNEL_VER.img.bak
# Move the new one into place
mv /boot/instrumented_initrd /boot/initramfs-$KERNEL_VER.img
# Script Finished
echo "Process Complete - reboot the system for the changes to take effect."
echo "After reboot, verify success with command 'dmesg | grep -i spi'"
The resulting device list is:
[root#localhost ~]# ls /dev/spi*
/dev/spidev1.0 /dev/spidev1.1 /dev/spidev2.0 /dev/spidev2.1 /dev/spidev3.0 /dev/spidev3.1

unable to attach ubi to mtd partition

We are using MT29F8G08ABABA in our DM365 based custom board.
We are using NAND boot.
RootFS is in UBIFS format,
Below is basic achitecture of the NAND.
I am using following commands to create ubifs,
$(UBIFS_PATH)/mkfs.ubifs -r $(TARGET_FS) -m 4096 -e 520192 -c 75 -o ubifs.img
$(UBIFS_PATH)/ubinize -o $(SYSTEM_CFG)_$(HARDWARE_CFG)_ubifs -m 4096 -p 512KiB $(HARDWARE_CFG)_ubinize.cfg
dm368_ubinize.cfg content is as follows,
[ubifs]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=37888KiB
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
Then i put this ubifs to NAND using following commands,
loady 0x82000000 ---> ubifs is loaded to RAM
nand scrub 0x1800000 0x2800000
nand erase 0x1800000 0x2800000
nand write 0x82000000 0x1800000 0x2800000
and when i boot the kernel there is error while detecting UBIFS from kernel,
Below is kernel log for the same,
[ 0.000000] Linux version 2.6[ 0.000000] Linux version 2.6.37_IPNC_DM368_5.1.0 (still-image#stillimage-VirtualBox) (gcc version 4.3.3 (GCC) ) #1 PREEMPT Sat Jan 4 11:09:29 IST 2014
[ 0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
[ 0.000000] CPU: VIVT data cache, VIVT instruction cache
[ 0.000000] Machine: DaVinci DM36x IPNC
[ 0.000000] Memory policy: ECC disabled, Data cache writeback
[ 0.000000] DaVinci dm36x_rev1.2 variant 0x8
[ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 12192
[ 0.000000] Kernel command line: mem=48M console=ttyS0,115200n8 noinitrd ip=off rw ubi.mtd=3,4096 rootfstype=ubifs root=ubi0:rootfs cmemk.phys_start=0x83000000 cmemk.phys_end=0x88000000 cmemk.phys_start_1=0x00001000 cmemk.phys_end_1=0x00008000 cmemk.pools_1=1x28672 cmemk.allowOverlap=1 cmemk.useHeapIfPoolUnavailable=1 nohz=off highres=off clocksource=acpi_pm lpj=1077248
[ 0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[ 0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[ 0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[ 0.000000] Memory: 48MB = 48MB total
[ 0.000000] Memory: 44772k/44772k available, 4380k reserved, 0K highmem
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
[ 0.000000] DMA : 0xff000000 - 0xffe00000 ( 14 MB)
[ 0.000000] vmalloc : 0xc3800000 - 0xfea00000 ( 946 MB)
[ 0.000000] lowmem : 0xc0000000 - 0xc3000000 ( 48 MB)
[ 0.000000] modules : 0xbf000000 - 0xc0000000 ( 16 MB)
[ 0.000000] .init : 0xc0008000 - 0xc002c000 ( 144 kB)
[ 0.000000] .text : 0xc002c000 - 0xc0390000 (3472 kB)
[ 0.000000] .data : 0xc0390000 - 0xc03b6600 ( 154 kB)
[ 0.000000] SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] Preemptable hierarchical RCU implementation.
[ 0.000000] RCU-based detection of stalled CPUs is disabled.
[ 0.000000] Verbose stalled-CPUs detection is disabled.
[ 0.000000] NR_IRQS:245
[ 0.000000] Console: colour dummy device 80x30
[ 0.000407] Calibrating delay loop (skipped) preset value.. 215.44 BogoMIPS (lpj=1077248)
[ 0.000494] pid_max: default: 32768 minimum: 301
[ 0.000794] Security Framework initialized
[ 0.001001] Mount-cache hash table entries: 512
[ 0.002188] CPU: Testing write buffer coherency: ok
[ 0.004944] devtmpfs: initialized
[ 0.010877] DaVinci: 8 gpio irqs
[ 0.011931] NET: Registered protocol family 16
[ 0.066045] dm365_rmd_cs_rdk_150_wl_init
[ 0.066124] No entry for the specified index
[ 0.069960] No entry for the specified index
[ 0.192448] bio: create slab <bio-0> at 0
[ 0.199765] SCSI subsystem initialized
[ 0.206445] usbcore: registered new interface driver usbfs
[ 0.208607] usbcore: registered new interface driver hub
[ 0.210484] usbcore: registered new device driver usb
[ 0.215823] vpss vpss: dm365_vpss vpss probed
[ 0.215919] vpss vpss: dm365_vpss vpss probe success
[ 0.222681] Advanced Linux Sound Architecture Driver Version 1.0.23.
[ 0.228358] Switching to clocksource timer0_1
[ 0.356682] NET: Registered protocol family 2
[ 0.357150] IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.358399] TCP established hash table entries: 2048 (order: 2, 16384 bytes)
[ 0.358604] TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.358736] TCP: Hash tables configured (established 2048 bind 2048)
[ 0.358784] TCP reno registered
[ 0.358845] UDP hash table entries: 256 (order: 0, 4096 bytes)
[ 0.358939] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[ 0.359791] NET: Registered protocol family 1
[ 0.466150] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 0.469156] JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[ 0.474898] msgmni has been set to 87
[ 0.481735] io scheduler noop registered (default)
[ 0.484414] CSL: Module install successful, device major num = 254
[ 0.484478] CSL: Module version 0.10.00, built on Dec 13 2013 22:33:02
[ 0.484552] I2C: Module install successful, device major num = 253
[ 0.484609] DMA: Module install successful, device major num = 252
[ 0.484654] DRV: Module install successful
[ 0.484692] DRV: Module built on Dec 13 2013 22:33:04
[ 0.484733] DRV: EDMACC.QUEPRI = 00002777
[ 0.484769] DRV: SYSTEM.MSTPRI0 = 00440011
[ 0.484804] DRV: SYSTEM.MSTPRI1 = 00000444
[ 0.484839] DRV: ISP.BCR = 00000002
[ 0.484874] DRV: SYSTEM.MISC = 00000399
[ 0.484911] EDMAK module: built on Dec 13 2013 at 22:32:35
[ 0.484957] Reference Linux version 2.6.37
[ 0.484996] File /opt/workdir/OV9715_Ver5_0/dvsdk_ipnctools/linuxutils_2_26_02_05/packages/ti/sdo/linuxutils/edma/src/module/edmak.c
[ 0.487539] IRQK module: built on Dec 13 2013 at 22:32:33
[ 0.487612] Reference Linux version 2.6.37
[ 0.487653] File /opt/workdir/OV9715_Ver5_0/dvsdk_ipnctools/linuxutils_2_26_02_05/packages/ti/sdo/linuxutils/irq/src/module/irqk.c
[ 0.490558] irqk initialized
[ 0.490663] CMEMK module: built on Dec 13 2013 at 22:32:30
[ 0.490723] Reference Linux version 2.6.37
[ 0.490762] File /opt/workdir/OV9715_Ver5_0/dvsdk_ipnctools/linuxutils_2_26_02_05/packages/ti/sdo/linuxutils/cmem/src/module/cmemk.c
[ 0.498082] allocated heap buffer 0xc4000000 of size 0x5000000
[ 0.498145] heap fallback enabled - will try heap if pool buffer is not available
[ 0.498205] CMEM Range Overlaps Kernel Physical - allowing overlap
[ 0.498257] CMEM phys_start (0x1000) overlaps kernel (0x80000000 -> 0x83000000)
[ 0.498473] cmemk initialized
[ 0.498551] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[ 0.611337] serial8250.0: ttyS0 at MMIO 0x1c20000 (irq = 40) is a 16550A
[ 1.137052] console [ttyS0] enabled
[ 1.211160] serial8250.0: ttyS1 at MMIO 0x1d06000 (irq = 41) is a 16550A
[ 1.254825] brd: module loaded
[ 1.272762] NAND device: Manufacturer ID: 0x2c, Chip ID: 0x38 (Micron )
[ 1.281908] Bad block table not found for chip 0
[ 1.287959] Bad block table not found for chip 0
[ 1.292787] Scanning device for bad blocks
[ 1.729485] Creating 7 MTD partitions on "davinci_nand.0":
[ 1.735177] 0x000000000000-0x000000c00000 : "bootloader"
[ 1.748031] 0x000000c00000-0x000001400000 : "params"
[ 1.760990] 0x000001400000-0x000001800000 : "kernel"
[ 1.773829] 0x000001800000-0x000004000000 : "filesystem1"
[ 1.787411] 0x000004000000-0x000004800000 : "data1"
[ 1.800510] 0x000004800000-0x000007000000 : "filesystem2"
[ 1.813667] 0x000007000000-0x000040000000 : "data2"
[ 1.828113] davinci_nand davinci_nand.0: controller rev. 2.3
[ 1.839036] UBI: attaching mtd3 to ubi0
[ 1.843400] UBI: physical eraseblock size: 262144 bytes (256 KiB)
[ 1.849714] UBI: logical eraseblock size: 256000 bytes
[ 1.855391] UBI: smallest flash I/O unit: 2048
[ 1.860292] UBI: sub-page size: 512
[ 1.864953] UBI: VID header offset: 4096 (aligned 4096)
[ 1.871094] UBI: data offset: 6144
[ 1.877230] UBI error: validate_ec_hdr: bad data offset 8192, expected 6144
[ 1.884383] UBI error: validate_ec_hdr: bad EC header
[ 1.889484] UBI error: ubi_io_read_ec_hdr: validation failed for PEB 0
[ 1.896907] UBI error: ubi_init: cannot attach mtd3
[ 1.905311] spi_davinci spi_davinci.0: Controller at 0xfec66000
[ 1.970163] davinci_mdio davinci_mdio.0: davinci mdio revision 1.4
[ 1.976404] davinci_mdio davinci_mdio.0: no live phy, scanning all
[ 1.983779] davinci_mdio: probe of davinci_mdio.0 failed with error -5
[ 1.993145] i2c /dev entries driver
[ 2.000461] Linux media interface: v0.10
[ 2.005482] Linux video capture interface: v2.00
[ 2.013867] vpbe-osd vpbe-osd: OSD sub device probe success
[ 2.021111] vpbe-venc vpbe-venc: VENC sub device probe success
[ 2.028379] vpbe-v4l2 vpbe-v4l2: vpbe v4l2 device registered
[ 2.034923] Setting default output to Composite
[ 2.039507] Setting default mode to ntsc
[ 2.043823] vpbe-v4l2 vpbe-v4l2: Trying to register VPBE display device.
[ 2.050741] vpbe-v4l2 vpbe-v4l2: layer=c2989a00,layer->video_dev=c2989ae8
[ 2.059118] vpbe-v4l2 vpbe-v4l2: Trying to register VPBE display device.
[ 2.066191] vpbe-v4l2 vpbe-v4l2: layer=c2989c00,layer->video_dev=c2989ce8
[ 2.076313] watchdog watchdog: heartbeat 60 sec
[ 2.090661] Error: Driver 'davinci-mcbsp' is already registered, aborting...
[ 2.102840] asoc: cq93vc-hifi <-> davinci-vcif mapping ok
[ 2.115028] ALSA device list:
[ 2.118092] #0: DaVinci DM365 EVM
[ 2.123853] nf_conntrack version 0.5.0 (699 buckets, 2796 max)
[ 2.133076] ip_tables: (C) 2000-2006 Netfilter Core Team
[ 2.138907] TCP cubic registered
[ 2.142616] NET: Registered protocol family 17
[ 2.163517] UBIFS error (pid 1): ubifs_mount: cannot open "ubi0:rootfs", error -19
[ 2.171615] VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0)
[ 2.178710] Please append a correct "root=" boot option; here are the available partitions:
[ 2.187357] 1f00 12288 mtdblock0 (driver?)
[ 2.192678] 1f01 8192 mtdblock1 (driver?)
[ 2.197807] 1f02 4096 mtdblock2 (driver?)
[ 2.203056] 1f03 40960 mtdblock3 (driver?)
[ 2.208184] 1f04 8192 mtdblock4 (driver?)
[ 2.213414] 1f05 40960 mtdblock5 (driver?)
[ 2.218542] 1f06 933888 mtdblock6 (driver?)
[ 2.223740] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 2.232105] Backtrace:
[ 2.234600] Function entered at [<c0030504>] from [<c030ec74>]
[ 2.240524] r7:00008000 r6:c2813000 r5:c00263ec r4:c03b6e00
[ 2.246275] Function entered at [<c030ec5c>] from [<c030ecd4>]
[ 2.252188] Function entered at [<c030ec78>] from [<c0008fdc>]
[ 2.258049] r3:00000000 r2:c2824000 r1:c2825f78 r0:c0331f90
[ 2.263847] Function entered at [<c0008d78>] from [<c0009134>]
[ 2.269707] Function entered at [<c00090a0>] from [<c00084b4>]
[ 2.275614] r5:c002597c r4:c03b6618
[ 2.279248] Function entered at [<c00083a4>] from [<c0046a58>]
[ 2.285156] r5:c00083a4 r4:00000000
Now my doubt is why kernel is reporting physical eraseblock size as 256KiB? from architecture of NAND it looks to be 512KiB.
Any suggestions/pointer for the errors ?
Thank you in advance
As i have mentioned in above answer,
I was not able to create a file or folder because filesystem size and partitions size was same.
So i increased the partition size to 128MB(nand_partition in kernel) and i recreated the UBIFS. I flashed the new kernel and UBIFS in NAND.
And it started working, now i am able to create folder and/or file anywhere in the root file system.
I used below commands to create ubifs,
$(UBIFS_PATH)/mkfs.ubifs -r $(TARGET_FS) -m 2048 -e 258048 -c 506 -o ubifs.img
$(UBIFS_PATH)/ubinize -o $(SYSTEM_CFG)_$(HARDWARE_CFG)_ubifs -m 2048 -p 256KiB -O 2048 $(HARDWARE_CFG)_ubinize.cfg
content of ubinize.cfg is as follows,
[ubifs]
peb=0x40000
min_io_size=0x800
compress_type=zlib
mode=ubi
image=ubifs.img
vol_id=0
vol_size=124MiB
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
Some calculations which will help understand
For 256Kib and pagesize 2048
Symbol Meaning Value for 128MB fs
SP PEB Size 256KiB
SL LEB Size 256kib - 2* 2kiB = 252Kib
P Total number of PEBs on the MTD device 128MiB / 256KiB = 512
B Number of PEBs reserved for bad PEB handling 1% of P = 5
O The overhead related to storing EC and VID headers in bytes, i.e. O = SP - SL 4KiB
UBI Overhead = (B + 4) * SP + O * (P - B - 4)
= (5 + 4) * 256Kib + 4 KiB * (512 - 5 - 4)
= 2304Kib + 2012Kib
= 4316 KiB
= 16.859375 PEBs (round to 17)
512 - 17 = 498 peb = 498*256kiB PEBS = 127488KiB availble for user data
we have to use -c <X> where x = 127488Kib / 252kib = 505.9 = 506
Hope this helps someone facing the similar issue.
PEB size (physical erase block) I think needs configuring as part of the ubinize config file, try adding something like this to the file:
[flash]
peb=0x20000
min_io_size=0x800
compress_type=zlib
(I've got a PEB size of 128KiB, so you'll need to change accordingly).
Also you might find UBIFS MTD pages useful - there's a question about bad VID header offset.
Hope this helps.

Parse MegaCLI output using BASH

I am dumping the complete configuration output of my 2 RAID controllers using LSI's MegaCLI command. I would like to parse the text file and print out only the lines I am interested in. For example:
"Adapter"
"Product Name"
"RAID Level Size State"
"Number Of Drives"
"Physical Disk"
"Raw Size"
"Link Speed"
"Media Type"
"Drive Temperature"
However, given the fact that the file contains configuration data for 2 RAID controller cards in descending order, how would I best approach this task using ONLY BASH! Below is the output I am dealing with.
NOTE: I should mention that I plan on installing another RAID controller soon, so ideally I would want to use something like BASH's 'read' built-in to read in the file. That way, the script will automatically catch a newly installed RAID controllers config data.
==============================================================================
Adapter: 0
Product Name: Supermicro SMC2208
Memory: 1024MB
BBU: Absent
Serial No:
==============================================================================
Number of DISK GROUPS: 1
DISK GROUP: 0
Number of Spans: 1
SPAN: 0
Span Reference: 0x00
Number of PDs: 2
Number of VDs: 1
Number of dedicated Hotspares: 0
Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name :
RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0
Size : 54.947 GB
Sector Size : 512
Mirror Data : 54.947 GB
State : Optimal
Strip Size : 64 KB
Number Of Drives : 2
Span Depth : 1
Default Cache Policy: WriteThrough, ReadAhead, Cached, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAhead, Cached, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy : Enabled
Encryption Type : None
Bad Blocks Exist: No
PI type: No PI
Is VD Cached: No
Physical Disk Information:
Physical Disk: 0
Enclosure Device ID: 252
Slot Number: 0
Drive's postion: DiskGroup: 0, Span: 0, Arm: 0
Enclosure position: N/A
Device Id: 5
WWN: 5001517803d94502
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SATA
Raw Size: 55.899 GB [0x6fccf30 Sectors]
Non Coerced Size: 55.399 GB [0x6eccf30 Sectors]
Coerced Size: 54.947 GB [0x6de5000 Sectors]
Sector Size: 512
Firmware state: Online, Spun Up
Commissioned Spare : No
Emergency Spare : No
Device Firmware Level: 300i
Shield Counter: 0
Successful diagnostics completion on : N/A
SAS Address(0): 0x4433221103000000
Connected Port Number: 1(path0)
Inquiry Data: CVMP302300A6060AGN INTEL SSDSC2CT060A3 300i
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None
Device Speed: 6.0Gb/s
Link Speed: 6.0Gb/s
Media Type: Solid State Device
Drive Temperature : N/A
PI Eligibility: No
Drive is formatted for PI information: No
PI: No PI
Port-0 :
Port status: Active
Port's Linkspeed: 6.0Gb/s
Drive has flagged a S.M.A.R.T alert : No
Physical Disk: 1
Enclosure Device ID: 252
Slot Number: 1
Drive's postion: DiskGroup: 0, Span: 0, Arm: 1
Enclosure position: N/A
Device Id: 2
WWN: 5001517803d855bb
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SATA
Raw Size: 55.899 GB [0x6fccf30 Sectors]
Non Coerced Size: 55.399 GB [0x6eccf30 Sectors]
Coerced Size: 54.947 GB [0x6de5000 Sectors]
Sector Size: 512
Firmware state: Online, Spun Up
Commissioned Spare : No
Emergency Spare : No
Device Firmware Level: 300i
Shield Counter: 0
Successful diagnostics completion on : N/A
SAS Address(0): 0x4433221102000000
Connected Port Number: 0(path0)
Inquiry Data: CVMP3020013L060AGN INTEL SSDSC2CT060A3 300i
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None
Device Speed: 6.0Gb/s
Link Speed: 6.0Gb/s
Media Type: Solid State Device
Drive Temperature : N/A
PI Eligibility: No
Drive is formatted for PI information: No
PI: No PI
Port-0 :
Port status: Active
Port's Linkspeed: 6.0Gb/s
Drive has flagged a S.M.A.R.T alert : No
==============================================================================
Adapter: 1
Product Name: Supermicro SMC2208
Memory: 1024MB
BBU: Absent
Serial No:
==============================================================================
Number of DISK GROUPS: 1
DISK GROUP: 0
Number of Spans: 1
SPAN: 0
Span Reference: 0x00
Number of PDs: 2
Number of VDs: 1
Number of dedicated Hotspares: 0
Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name :
RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0
Size : 54.947 GB
Sector Size : 512
Mirror Data : 54.947 GB
State : Optimal
Strip Size : 64 KB
Number Of Drives : 2
Span Depth : 1
Default Cache Policy: WriteThrough, ReadAhead, Cached, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAhead, Cached, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy : Enabled
Encryption Type : None
Bad Blocks Exist: No
PI type: No PI
Is VD Cached: No
Physical Disk Information:
Physical Disk: 0
Enclosure Device ID: 252
Slot Number: 0
Drive's postion: DiskGroup: 0, Span: 0, Arm: 0
Enclosure position: N/A
Device Id: 5
WWN: 5001517803d94502
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SATA
Raw Size: 55.899 GB [0x6fccf30 Sectors]
Non Coerced Size: 55.399 GB [0x6eccf30 Sectors]
Coerced Size: 54.947 GB [0x6de5000 Sectors]
Sector Size: 512
Firmware state: Online, Spun Up
Commissioned Spare : No
Emergency Spare : No
Device Firmware Level: 300i
Shield Counter: 0
Successful diagnostics completion on : N/A
SAS Address(0): 0x4433221103000000
Connected Port Number: 1(path0)
Inquiry Data: CVMP302300A6060AGN INTEL SSDSC2CT060A3 300i
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None
Device Speed: 6.0Gb/s
Link Speed: 6.0Gb/s
Media Type: Solid State Device
Drive Temperature : N/A
PI Eligibility: No
Drive is formatted for PI information: No
PI: No PI
Port-0 :
Port status: Active
Port's Linkspeed: 6.0Gb/s
Drive has flagged a S.M.A.R.T alert : No
Physical Disk: 1
Enclosure Device ID: 252
Slot Number: 1
Drive's postion: DiskGroup: 0, Span: 0, Arm: 1
Enclosure position: N/A
Device Id: 2
WWN: 5001517803d855bb
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SATA
Raw Size: 55.899 GB [0x6fccf30 Sectors]
Non Coerced Size: 55.399 GB [0x6eccf30 Sectors]
Coerced Size: 54.947 GB [0x6de5000 Sectors]
Sector Size: 512
Firmware state: Online, Spun Up
Commissioned Spare : No
Emergency Spare : No
Device Firmware Level: 300i
Shield Counter: 0
Successful diagnostics completion on : N/A
SAS Address(0): 0x4433221102000000
Connected Port Number: 0(path0)
Inquiry Data: CVMP3020013L060AGN INTEL SSDSC2CT060A3 300i
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None
Device Speed: 6.0Gb/s
Link Speed: 6.0Gb/s
Media Type: Solid State Device
Drive Temperature : N/A
PI Eligibility: No
Drive is formatted for PI information: No
PI: No PI
Port-0 :
Port status: Active
Port's Linkspeed: 6.0Gb/s
Drive has flagged a S.M.A.R.T alert : No
Exit Code: 0x00
When you say "ONLY BASH", do you really mean it? bash by itself is pretty powerless; it really depends on having a collection of non-builtin commands available to do anything nontrivial. Also, do you really just want the selected lines, or do you want to reformat the info at all?
If you just want the lines (and maybe a little header info) and have egrep available, this is simple:
MegaCLI -whateveroptions | egrep '^(Adapter|Product Name|RAID Level Size State|Number Of Drives|Physical Disk|Raw Size|Link Speed|Media Type|Drive Temperature):`
If you really need 100% pure bash, you can do it with read, case, and echo:
MegaCLI -whateveroptions | while read line; do
case "$line" in
Adapter:* | \
Product Name:* | \
RAID Level Size State:* | \
Number Of Drives:* | \
Physical Disk:* | \
Raw Size:* | \
Link Speed:* | \
Media Type:* | \
Drive Temperature:* )
echo "$line" ;;
esac
done
If you get sick of parsing this stuff I would consider using a newer LSI controller and the StorCLI64 binary. StorCLI is somewhat similar to MegaCLI, but allows you to append " J" to every command to have the response returned in JSON.

Resources