What I actually did - disabled CONFIG_MPU in kernel and it started to work. After that I found that my u-boot is custom fork and probably doesn't setup MPU well. Without CONFIG_MPU everything started to work great. So I could say linuxthreads.old work on M3 with 3 patches provided by Sergei over 0.9.33.2 release
On Mon, Nov 3, 2014 at 5:58 PM, Andrii <[email protected]> wrote: > uClibc was built with: make ARCH_CFLAGS= 'CPU_CFLAGS=-mthumb -march=armv7 > -mfix-cortex-m3-ldrd' > App was built with: arm-uclinuxeabi-gcc -c -g -mthumb -march=armv7 > -mfix-cortex-m3-ldrd -O0 -Wl,-elf2flt,--static main.c > arm-uclinuxeabi-gcc -Wl,-elf2flt,--static main.o > -L../arm-2010q1/arm-uclinuxeabi/libc/thumb2/usr/lib -lpthread -o zpm_thread > where all original uclibc libraries from toolchain were replaced with > newly built ones: > /mnt/repos/repos/github/uclibc$ ls -la > /mnt/repos/repos/github/nocturn_tools/arm-2010q1/arm-uclinuxeabi/libc/thumb2/usr/lib > total 1412 > drwxrwxr-x 2 repu1sion repu1sion 4096 Nov 3 17:32 . > drwxrwxr-x 5 repu1sion repu1sion 4096 Aug 25 22:50 .. > -rw-rw-r-- 1 repu1sion repu1sion 992 Nov 3 17:32 crt1.o > -rw-rw-r-- 1 repu1sion repu1sion 959 Nov 3 17:32 crti.o > -rw-rw-r-- 1 repu1sion repu1sion 959 Nov 3 17:32 crtn.o > -rw-rw-r-- 1 repu1sion repu1sion 1130956 Nov 3 17:32 libc.a > -rw-rw-r-- 1 repu1sion repu1sion 175768 Nov 3 17:32 libm.a > -rw-rw-r-- 1 repu1sion repu1sion 90352 Nov 3 17:32 libpthread.a > -rw-rw-r-- 1 repu1sion repu1sion 1082 Nov 3 17:32 libresolv.a > -rw-rw-r-- 1 repu1sion repu1sion 14084 Nov 3 17:32 librt.a > > > > On Mon, Nov 3, 2014 at 5:53 PM, Andrii <[email protected]> wrote: > >> I've tried to apply Sergei' 3 patches to the original 0.9.33.2 and run >> test app on it. >> Still got a crash: >> >> / # /opt/zpm_thread >> 00032 : pthread_initialize: initial thread stack bounds: bos=0x1, >> tos=0xffffffff >> 00032 : __pthread_initialize_manager: manager stack: size=8160, >> bos=0xa00a2008, tos=0xa00a3fe8 >> 00032 : __pthread_initialize_manager: send REQ_DEBUG to manager thread >> 00032 : pthread_create: write REQ_CREATE to manager thread >> 00032 : pthread_create: before suspend(self) >> 00033 : __pthread_manager: before poll >> 00033 : __pthread_manager: after poll >> 00033 : __pthread_manager: before read >> 00033 : __pthread_manager: after read, n=28 >> 00033 : __pthread_manager: got REQ_CREATE >> 00033 : pthread_allocate_stack: malloced chunk: base=0xa00a8008, >> size=0x4000 >> 00033 : pthread_allocate_stack: thread stack: bos=0xa00a8008, >> tos=0xa00abea8 >> 00033 : pthread_allocate_stack: initial stack: bos=0x1, tos=0xa00a2008 >> 00033 : pthread_handle_create: cloning new_thread = 0xa00abea8 >> 00033 : pthread_handle_create: new thread pid = 34 >> 00033 : __pthread_manager: restarting 0xa008e8d0 >> 00032 : pthread_create: after suspend(self) >> thread #0 created >> 00033 : __pthread_manager: before poll >> 00034 : pthread_start_thread: >> new thread 1 executed. >> 00032 : pthread_create: write REQ_CREATE to manager thread >> 00032 : pthread_create: before suspend(self) >> 00033 : __pthread_manager: after poll >> 00033 : __pthread_manager: before read >> 00033 : __pthread_manager: after read, n=28 >> 00033 : __pthread_manager: got REQ_CREATE >> 00033 : pthread_allocate_stack: malloced chunk: base=0xa03d8008, >> size=0x4000 >> 00033 : pthread_allocate_stack: thread stack: bos=0xa03d8008, >> tos=0xa03dbea8 >> 00033 : pthread_allocate_stack: initial stack: bos=0x1, tos=0xa00a2008 >> 00033 : pthread_handle_create: cloning new_thread = 0xa03dbea8 >> 00033 : pthread_handle_create: new thread pid = 35 >> 00033 : __pthread_manager: restarting 0xa008e8d0 >> 00033 : __pthread_manager: before poll >> 00035 : pthread_start_thread: >> new thread 1 executed. >> 00032 : pthread_create: after suspend(self) >> thread #1 created >> 00032 : pthread_create: write REQ_CREATE to manager thread >> 00033 : __pthread_manager: after poll >> 00033 : __pthread_manager: before read >> 00033 : __pthread_manager: after read, n=28 >> 00033 : __pthread_manager: got REQ_CREATE >> 00032 : pthread_create: before suspend(self) >> >> [ 12.390000] >> [ 12.390000] zpm_thread: unhandled MPU fault (0x08) at 0x00000000 >> [pc=0xa0084c74,sp=0xa00a3f20] >> [ 12.390000] >> [ 12.390000] Pid: 33, comm: zpm_thread >> [ 12.390000] CPU: 0 Not tainted (2.6.33-arm1 #2) >> [ 12.390000] pc : [<a0084c74>] lr : [<a008478f>] psr: 21000000 >> [ 12.390000] sp : a00a3f20 ip : 5220746f fp : 00000803 >> [ 12.390000] Code dump at pc [a0084c74]: >> [ 12.390000] a003f848 463b4621 ff98f7ff 681b4b04 >> [ 12.390000] r10: 00005000 r9 : 00000003 r8 : a0020000 >> [ 12.390000] r7 : a0092f04 r6 : 00000100 r5 : a0092e0c r4 : a0024ff4 >> [ 12.390000] r3 : 00004ff4 r2 : 00000000 r1 : a0092e10 r0 : a0092e0c >> [ 12.390000] Flags: nzCv IRQs on FIQs on Mode USER_26 ISA unknown >> Segment user >> [ 12.390000] Backtrace: invalid frame pointer 0x00000803 >> >> From my observations it crashes in malloc() during allocation of 16Kb >> stack for a new thread while trying to find and link a new free area. >> >> Here is the app code. It's trivial: >> >> #include <stdio.h> >> #include <stdlib.h> >> #include <unistd.h> >> #include <string.h> >> #include <pthread.h> >> >> #define NUM_THREADS 10 >> >> pthread_t thread[NUM_THREADS] = {0}; >> int thread_cnt = 0; >> >> void* start_routine(void *arg) >> { >> printf("new thread %d executed.\n", thread_cnt); >> while(1) >> { >> sleep(1); >> } >> } >> >> void main() >> { >> int i; >> int rv; >> >> for (i = 0; i < NUM_THREADS; i++) >> { >> rv = pthread_create(&thread[thread_cnt], NULL, >> start_routine, NULL); >> if (rv) >> printf("<error> thread was not created! Error num >> is : %d\n", rv); >> printf("thread #%d created \n", thread_cnt); >> thread_cnt++; >> sleep(1); >> } >> while(1) >> { >> static int loop_cnt = 0; >> printf("app loop: %d\n", loop_cnt); >> sleep(1); >> loop_cnt++; >> if (loop_cnt == 10) >> break; >> } >> } >> >> uClibc config is attached. >> >> Could someone please try it on M3 and tell me the results? >> >> Regards. >> >> >> >> >> On Sat, Nov 1, 2014 at 10:52 AM, Sergei Poselenov <[email protected] >> > wrote: >> >>> Hello, >>> >>> On Thu, 2014-10-23 at 17:25 +0200, Bernhard Reutner-Fischer wrote: >>> > On 22 October 2014 12:11:26 CEST, Sergei Poselenov < >>> [email protected]> wrote: >>> > >Hello, >>> > > >>> > >>> > >Uclibc (still) lacks pthreads support on Cortex-M3. >>> > > >>> > >I'm attaching two patches: >>> > > - implement testandset() for Cortex-M3. >>> > > - Fix a bug in implementation of clone() for Cortex-M3. >>> > >>> > Can you please send the two patches with appropriate signed-off-by >>> lines? >>> >>> I'm sending the patches made against the pristine 0.9.33.2 in the next >>> emails. Note that the changes may be not quite portable, feel free to >>> modify them. >>> >>> Regards, >>> >>> Sergei >>> > TIA, >>> > >>> >>> >>> >> > _______________________________________________ uClibc mailing list [email protected] http://lists.busybox.net/mailman/listinfo/uclibc
