Forum: Mikrocontroller und Digitale Elektronik Nuttx heap allocation failed: heap-size is zero


von Stephan R. (rabbe)


Angehängte Dateien:

Lesenswert?

Ich versuche gerade Speicher auf mm_heap zu allozieren, aber die 
Heap-Size ist Null:

Daher schlägt die Speicher-Allozierung immer fehl.

Meine Frage: Wie kann ich das Problem debuggen, bzw. wo kann ich die 
Heap-Size für meinen uC einstellen?

Ich nutze Nuttx auf einen STM32F765 uC.

von Alan C. (acassis)


Lesenswert?

Hallo Stephan

Bitte versuchen Sie die "Memory Manager Debug Features" (Error, Warn and 
Info) in den "make menuconfig" -> "Build Setup" -> "Debug Options" zu 
aktivieren.

Wenn Sie Englisch sprechen können, abonnieren Sie bitte die 
NuttX-Mailingliste bei Google Groups.

Freundliche Grüße,

Alan

PS .: Ich habe den Google Übersetzer benutzt, um Ihnen zu antworten (ich 
spreche kein Deutsch), ich hoffe, dass alles korrekt übersetzt wurde.

von Flo H. (hoeze)


Angehängte Dateien:

Lesenswert?

Hi Alan, thanks for your answer.
As you suggested, we enabled the debugging options in menuconfig.

When debugging NuttX on the uC, we now get the following logs (see also 
appended screenshot):
1
gpio_pin_register: Registering /dev/gpout0
2
mm_malloc: WARNING: Allocation failed, size 48
3
mm_initialize: Heap: start=0x200219a0 size=370272
4
mm_addregion: Region 1: base=0x200219a0 size=370272

stack trace:
1
Thread #1 (Suspended : Step)  
2
  mm_zalloc() at mm_zalloc.c:60 0x800a048  
3
  zalloc() at umm_zalloc.c:83 0x800987c  
4
  inode_alloc() at fs_inodereserve.c:94 0x801c276  
5
  inode_reserve() at fs_inodereserve.c:223 0x801c362  
6
  register_driver() at fs_registerdriver.c:87 0x8015cd8  
7
  gpio_pin_register() at gpio.c:588 0x8006de6  
8
  stm32_gpio_initialize() at stm32_gpio.c:257 0x80027b4  
9
  stm32_boardinitialize() at stm32_boot.c:105 0x800263c  
10
  __start() at stm32_start.c:370 0x80002f4

variables:
1
heap  struct mm_heap_s *  0x20021410 <g_mmheap>  
2
  mm_semaphore  sem_t  {...}  
3
    semcount  volatile int16_t  0  
4
  mm_holder  pid_t  0  
5
  mm_counts_held  int  0  
6
  mm_heapsize  size_t  0  
7
  mm_heapstart  struct mm_allocnode_s *[3]  0x2002141c <g_mmheap+12>  
8
    mm_heapstart[0]  struct mm_allocnode_s *  0x0  
9
    mm_heapstart[1]  struct mm_allocnode_s *  0x0  
10
    mm_heapstart[2]  struct mm_allocnode_s *  0x0  
11
  mm_heapend  struct mm_allocnode_s *[3]  0x20021428 <g_mmheap+24>  
12
    mm_heapend[0]  struct mm_allocnode_s *  0x0  
13
    mm_heapend[1]  struct mm_allocnode_s *  0x0  
14
    mm_heapend[2]  struct mm_allocnode_s *  0x0  
15
  mm_nregions  int  0  
16
  mm_nodelist  struct mm_freenode_s [19]  0x20021438 <g_mmheap+40>  
17
size  size_t  27  
18
alloc  void *  0x0

---------------

When simply restarting NuttX, we obtain these logs:
1
gpio_pin_register: Registering /dev/gpout0
2
mm_malloc: WARNING: Allocation failed, size 48
3
mm_initialize: Heap: start=0x200219a0 size=370272
4
mm_addregion: Region 1: base=0x200219a0 size=370272
5
mm_malloc: Allocated 0x200219b0, size 400
6
mm_malloc: Allocated 0x20021b40, size 208
7
mm_malloc: Allocated 0x20021c10, size 336
8
mm_malloc: Allocated 0x20021d60, size 272
9
mm_malloc: Allocated 0x20021e70, size 144
10
mm_malloc: Allocated 0x20021f00, size 176
11
mm_malloc: Allocated 0x20021fb0, size 336
12
mm_malloc: Allocated 0x20022100, size 304
13
mm_addregion: Region 2: base=0x2007c000 size=16384
14
mm_addregion: Region 3: base=0x20000000 size=131072
15
stm32_dumpnvic: NVIC (initial, irq=126):
16
stm32_dumpnvic:   INTCTRL:    00000000 VECTAB:  08000000
17
stm32_dumpnvic:   IRQ ENABLE: 00000000 00000000 00000000
18
stm32_dumpnvic:   SYSH_PRIO:  00808080 80000000 80800080
19
stm32_dumpnvic:   IRQ PRIO:   80808080 80808080 80808080 80808080
20
stm32_dumpnvic:               80808080 80808080 80808080 80808080
21
stm32_dumpnvic:               80808080 80808080 80808080 80808080
22
stm32_dumpnvic:               80808080 80808080 80808080 80808080
23
stm32_dumpnvic:               80808080 80808080 80808080 80808080
24
stm32_dumpnvic:               80808080 80808080 80808080 80808080
25
stm32_dumpnvic:               80808080 80808080 80808080 00008080
26
mm_malloc: Allocated 0x2007c010, size 48
27
mm_malloc: Allocated 0x2007c040, size 48
28
mm_malloc: Allocated 0x2007c070, size 48
29
mm_malloc: Allocated 0x2007c0a0, size 48
30
mm_malloc: Allocated 0x2007c0d0, size 48
31
mm_malloc: Allocated 0x2007c100, size 48
32
mm_malloc: Allocated 0x2007c130, size 48
33
mm_malloc: Allocated 0x2007c160, size 48
34
mm_malloc: Allocated 0x2007c190, size 48
35
mm_malloc: Allocated 0x2007c1c0, size 48
36
mm_malloc: Allocated 0x2007c1f0, size 48
37
mm_malloc: Allocated 0x2007c220, size 496
38
mm_malloc: Allocated 0x2007c410, size 80
39
mm_malloc: Allocated 0x2007c460, size 80
40
mm_malloc: Allocated 0x2007c4b0, size 80
41
mm_malloc: Allocated 0x2007c500, size 32
42
mm_malloc: Allocated 0x2007c520, size 352
43
mm_malloc: Allocated 0x2007c680, size 496
44
mm_malloc: Allocated 0x2007c870, size 80
45
mm_malloc: Allocated 0x2007c8c0, size 80
46
mm_malloc: Allocated 0x2007c910, size 80
47
mm_malloc: Allocated 0x2007c960, size 2064
48
mm_malloc: Allocated 0x2007d170, size 352
49
mm_malloc: Allocated 0x2007d2d0, size 496
50
mm_malloc: Allocated 0x2007d4c0, size 80
51
mm_malloc: Allocated 0x2007d510, size 80
52
mm_malloc: Allocated 0x2007d560, size 80
53
mm_malloc: Allocated 0x2007d5b0, size 2064
54
mm_malloc: Allocated 0x2007ddc0, size 352
55
mm_malloc: Allocated 0x2007df20, size 496
56
mm_malloc: Allocated 0x2007e110, size 80
57
mm_malloc: Allocated 0x2007e160, size 80
58
mm_malloc: Allocated 0x2007e1b0, size 80
59
mm_malloc: Allocated 0x2007e200, size 2064
60
mm_malloc: Allocated 0x2007ea10, size 688
61
62
NuttShell (NSH)
63
nsh>

/dev/gpout0 does not show up on 'ls /dev'.

von Alan C. (acassis)


Lesenswert?

Hi Stephan,

I saw you subscribed to the NuttX mailing list, please post this 
question there before someone here start to complain we are not speaking 
in German.

BTW, based on your log it appears you are calling 
stm32_gpio_initialize() before the heap initialization (before 
mm_addregion() ).

BR,

Alan

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.