-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIntW_Exp
More file actions
873 lines (595 loc) · 28.8 KB
/
Copy pathIntW_Exp
File metadata and controls
873 lines (595 loc) · 28.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
###########################################################################################
July17/2016: For NVIDIA through Aricent:
which drivers you worked on?? Have you worked on USB?
EEPROM-driver:
How do you read 10 bytes from EPROM? what is the use case of EPROM driver written?
when are the tasks created in your project compile time or runtime?
how to create tasks @ runtime?
when the sceduler is invoked? how to invoke it?
what is done in your device open ? ---could not able to put forward steps (better write @ some place - so glancing before going to intw may help)
what is device Initialisation . how you did it for EEPROM?
What is pinmuxing? what is pinconfiguration? how you did it?
after pinmux what you did ? - clock Initialisation
what is clock initialisation ? how you done this --> more detailed answer could have given
then what other things you done during device Initialisation?
If you wrote 10 bytes into UART buffer.and about to Enable the TX-Interrupt.but there is
context switch suddenly. How do you manage the situation??
what are memory barriers?
What is out of order Execution?
two instructions of Equal execution time may get executed out of order . why??
How do you write PS command of Linux?
Iterate through task_struct list and display the state of process
From where do you get the task_struct list ??
what do you pass to / how do you ask to get state of processes??
Insert a node in tree.
delete a node from tree.
program to check a flag and update the satus to user?
From where do you get the syscall number in system-call?
what happens during context switch from user space to kernel ??
How do you get the boot-args during run time ?
usrspace stack vs kernel space stack?
what is copy_to_user and copy_from-user? how they help in security??
you should know : page-tables,security in linux,user space and kernel space linux,ioremap
Feedback given by interviewer:
If you have Enough Knowledge , then Even if you don't have Project Experience: you will be hired.
you are going 2 steps in , but not the further 3 steps where you will touch bottom.
get Indepth Knowledge? dont do trial and Error? Analyse Each step why you are doing.
go through all course of action - from inserting usb stick till notification appears on screen
If you come 2 days befor i could have hired you,...those positions are filled .
now we need person very thourogh and well experienced.
Self Asseesment :
not going In depth - not understanding thoroughly Each step.
not Adventerous Enough to Experimentation : Learning new concepts, new subsystems,new devices
not doing work thouroughly and slowly: need more concentration
not having self confidence: believe that you can get job, If you do the work thoroughly,Even if it is very small.
Interview-Asseesment:
- not presented the work done ..very well infront of interviwer
- no indepth knowledge about Each concept touched.
Assesment about Interviewer:
- initially doubtful about me wether i have worked on drivers?
- slowly gained belief on me.
- since he felt i worked more on rtos and less on Linux side ..he didn't shoot many questions on Linux drivers
other wise there may be questions on probe , driver registration etc.
- Also i did not putforth many of the things i have actually done.--other wise intw could have taken a different path
and he might have selected me.-- i could have mentioned iomap
Action:
----------------
Undersatnding UART driver thoroughly:
june24 : wipro interview :
atoi Fn, str-reverseFn.
what is copy-on-write ? why used?
difference b/w mutex and semaphore ?
below is the interviewers expectation:
----> mutex can be relesed only by the process which acquired it.
semaphore can be released by any process / kernel ... how much this is correct?? does he mean that ...post is
done several times...and can be done by different processes.??
fork in a for loop --- he is asking for formula to know no.of processes.
how to make the static variable visible in other files?
what is the scope of static variable??
can the static variable be declared external??
delete node in binary tree ---> try this is not that straight forward as linked list.
Analysis:
Interviewers not very good at OS...but they questioned well in C,basic linux.
their behaviour was good .
this interview helped me to know my weak -points: i should be continously practice intw-aproach
keep practicing,c and DS basics...It helps to make impression during intw-for-PlatformJOB.
##############################################################################################
ADC driver :
i2c client driver reads from ADC(mcp 3021) and writes into sysfs.
also provides value to user space through ioctl interface.
mcp3021_adc_drv_init:
Allocate device numbers.
create class for device.
i2c_add_driver: register the i2c client driver( a platform driver) with the i2c subsystem.
mcp3021_probe:
create ,populate private structure and store it in struct i2c_client.
create sysfs files corresponding to attributes of kobjects of device.
sysfs_create_file(&client->dev.kobj, &dev_attr_in0_input.attr);
sysfs_create_file(&client->dev.kobj, &dev_attr_dig_val.attr);
init and add cdev
create device in class.
static DEVICE_ATTR(in0_input, S_IRUGO, show_in_input, NULL);
static DEVICE_ATTR(dig_val, S_IRUGO, show_dig_val, NULL);
show_dig_val : mcp3021_read16 => print reg
show_in_input : mcp3021_read16 => conv regval to volts : print volts
mcp3021_read16 : i2c_master_recv(client, (char *)&buf, 2);
#####################################################################################################
UART_INIT:
Allocate device numbers
create class for uart
Register the uart driver with Platform subsystem
UART_EXIT:
UnRegister the uart driver with Platform subsystem.
destroy the class uart
Free the device numbers allocated.
UART-Probe:
-----------
possible Q's: when does the probe is called ?
what you do in probe of device(UART)
Enable UART TX and RX pins through pin-ctrl subsystems
Request_mem_region: Claim the memory region of
Allocate the private object of UART
io-remap
Initialise and add the cdev
create the device node
UART-OPEN
--------------
UART-Initialisation:
---------------------
possible Q's:
what is meant by device Initialisation? what you do during UART Initialisation?
uart clock Initialisation:
software reset of device
protocol,Baud rate and Interrupt settings
FIFO and DMA settings
should be done as per the steps provided in data sheet.
Deatiled steps:
(A)
1)Initiate a software reset : set SOFTRESET bit in UART_SYSC
2)Wait for the end of the reset operation : poll RESET_DONE bit of UART_SYSS
(B)
Switch to Config-Mode B to Access register EFR
3) Baud-Rate setting: 9.6Kbps/ 1.843Kbps/ 3.6884Kbps => Load divisor value in DLH,DLL
(C)
switch to operational-mode:
4) select b/w (single-granularity/N-granularity of FIFO-trigger level) /( DMA mode ) ===> TLR/TCR/FCR/SCR
5)set Tx-FIFO-trigger-level,Rx-FIFO-Trigger-level ,clear FIFO & Enable FIFO==> FCR-fifo control register.
6)Enable the baud-rate clock
(D)
Switch to Config-Mode B:
7)set data-width,stop-bit,no-parity ===> LCR
8)Disable the break-Ctrl ===> LCR
(E)
9)switch to operational-mode:
10)Disable all the Interrupts ===> IER
11)set the UART mode: 16X / 13X ==> MDR1
Allocate Tx and RX Kfifo-buffers
Initialise WaitQ's for Read and Write operations
Request IRQ : Install ISR
Enable Rx-Interrupt only
UART_release:
-------------------
Disable Interrupts
free irq
Free Tx and RX kfifo's
Disable UART==> MDR1 reg
UART_READ:
----------------
if Intermediate Rx_kfifo_buffer is Empty : do not allow the proces to read.
For a non-blocking read return -EAGAIN
For blockable read : suspend the user process till data becomes available in Intermediate Rx_kfifo_buffer.
put the process in Read-Wait-queue on the condition:till data becomes available in Rx_kfifo_buffer
once the data is available in Rx_kfifo_buffer : copy this to user buffer
UART_WRITE:
----------------
if Intermediate Rx_kfifo_buffer is full : do not allow the proces to write .
For a non-blocking write return -EAGAIN
For blockable write : suspend the user process till data becomes available in Intermediate Rx_kfifo_buffer.
put the process in write-Wait-queue on the condition:till space is available in Tx_kfifo_buffer.
once Tx_kfifo_buffer is empty : copy user buffer to Tx_kfifo_buffer.
UART_FLUSH:
--------------
Flush - is called when a process closes its copy of the descriptor.
suspend the user process till data in Tx_kfifo_buffer is emptied.
put the process in write-Wait-queue on the condition:till Tx_kfifo_buffer is emptied.
object's flush method is invoked on any and every close(),
the release method is invoked when the open file object's reference count drops to zero.
ISR of UART
----------------
check pending interrupts
Read IIR - : type of Interrupt which is higher in priority out of currently pending interrupts
if : RHR or Rx-timeout pending
copy all the available data from rx-uart-fifo into Internal Rx-kfifo-buffer ( RXFIFOE- rx-fifo-empty flag of LSR)
mark Any sleeping RD-thread as Runnable => waku-up thread on RD-waitQ
if : THR pending
copy data from tx-uart-fifo into Internal Tx-kfifo-buffer till all spaces in tx-uart-fifo level are filled.
(check for TXFIFOE -transmithold and shift registers are not empty condition)
mark Any sleeping WR-thread as Runnable => waku-up thread on WR-waitQ
Watch dog timer:
http://www.embedded.com/design/debug-and-optimization/4402288/Watchdog-Timer
Before kicking the watch-dog timer:
1) perform set of sanity checks - kick the dog only if all sanity checks pass . if Any check fails - allow dog to bite
2) Record cause of sanity check failure in EPROM - because sometimes it may be difficult to find cause after reset
3) bug-bite case ( if bite is due to S/W bug) : record the system state / currently active task state , valueble info
when trying to diagnose the problem.
4)
After dog-bite:
1)After reset , Examine status bit which indicates that bite occured : decide next course of Action
continue running / swich to Fail safe/ display Error-Msg
2)record number of bites - to avoid persistently errant application resarting indefinitely
3)
choosing timeout Interval: ===> when to kick the dog??
--------------------------
objec-tives of watch-dog strategy in a multitasking system:
-----------------------------------------------------------
1)To detect an OS fail-ure that is preventing some or all ofthe tasks from running
2)To detect an infinite loop in any task / deadlock b/w several tasks/
3)To detect low-priority tasks not running due to higher priority tasks hogging cpu
open WDT
//Initialise WDT ?? here ?
If( Normal reboot)
skip below steps.
if( watch-dog reboot) //bootstatus flag of watchdog
Increment the counter variable:kick_number
if( kick_number > 3) //on that day
Display : WDT+ERROR
else
read flag indicating Erraneous task From EPROM
Display : flag=>task caused watchdog reset
Read (state of system before reboot) / (state of task which caused reboot)
Display : Diagnostic Info regading state of system before reboot
proceed only if(watchdog-jumper is inserted )
else
Display: Watch-dog Jumper not inserted. and stop.
//Initialise WDT ?? here ?
Initialise watch-dog timer and send open-device handle to WDT monito task
create task1:bug_task:
configure a gpio-pin as i/p to get accept button press user i/p
Register with watchdog-monitor task
update flag1 only if switch is ON
create task2: periodic task with period 1ms
Register with watchdog-monitor task
update flag2 ,every 1ms
create task3: periodic task with period 1ms
Register with watchdog-monitor task
update flag3 ,every 2ms
create watch-dog_monitor task
check the flags of all the periodic tasks
If all flags updated - kick the dog
If any flag is not got updated -
store the flag in EEPROM
Avoid kicking the watch-dog
Analyse what are problems in kicking DOG from ISR??
Analyse How to monitor waiting tasks?
coding :
Application:
./FreeRTOS-Plus-Demo-1/Source/Examples/WDT/WDTManage.c
#define WATCHDOG_DEVICE (const int8_t *)"/WWDT0/" //aaa-zzz : wdt
Peripheral_Descriptor_t WDT_handle;
WDT_handle = FreeRTOS_open( WATCHDOG_DEVICE, flag );
BSP:
./FreeRTOS-Plus-Demo-1/Source/FreeRTOSIOConfig.h
#define ioconfigINCLUDE_WDT 1 //aaa-zzz : WDT
./FreeRTOS-Plus-Demo-1/Source/FreeRTOS-Products/FreeRTOS-Plus-IO/Device/LPC17xx/SupportedBoards/LPCXpresso17xx-base-board.h
#define boardAVAILABLE_DEVICES_LIST \
{ \
{ ( const int8_t * const ) "/WWDT0/", eWWDT_TYPE, ( void * ) LPC_WWDT }, \
{ ( const int8_t * const ) "/GPIO0/", eGPIO_TYPE, ( void * ) LPC_GPIO } \
}
#define boardNUM_WWDTS 1 //aaa-zzz :wdt
./FreeRTOS-Plus-Demo-1/Source/FreeRTOS-Products/FreeRTOS-Plus-IO/Include/FreeRTOS_DriverInterface.h
typedef enum
{.....
eWWDT_TYPE,
eGPIO_TYPE
} Peripheral_Types_t;
/FreeRTOS-Plus-Demo-1/Source/FreeRTOS-Products/FreeRTOS-Plus-IO/Device/LPC17xx/FreeRTOS_lpc17xx_DriverInterface.c
#include "FreeRTOS_wdt.h" //aaa-zzz : WDT
case eWWDT_TYPE :
#if ioconfigINCLUDE_WDT == 1 //aaa-zzz : WDT
{
xReturn = FreeRTOS_WWDT_open( pxPeripheralControl );
}
#endif
break;
./FreeRTOS-Plus-Demo-1/Source/FreeRTOS-Products/FreeRTOS-Plus-IO/Device/LPC17xx/FreeRTOS_LPC17xx_wdt.c
#include <FreeRTOS_wdt.h> //aaa-zzz
portBASE_TYPE FreeRTOS_WWDT_open( Peripheral_Control_t * const pxPeripheralControl )
{
return xReturn;
}
The Watchdog : a divide by 4 fixed pre-scaler and a 32-bit counter.
The clock is fed to the timer via a pre-scaler. The timer decrements when clocked.
The minimum value from which the counter decrements is 0xFF.
minimum Watchdog interval is = (T WDCLK * 256 * 4) = 10ms * 256 * 4 = 10ms x 4 x 256
maximum Watchdog interval is = (T WDCLK * 2^32 * 4) = 10ms x 2^32 x4 = 10ms x 4 x (2x1024x1024x1024)
= 10ms x 4 x (2 x 1073741824)
= 10ms x 4 x 2147483648
The watchdog timer block uses two clocks: PCLK and WDCLK. PCLK is used for the APB
accesses to the watchdog registers. The WDCLK is used for the watchdog timer counting.
embedded system startup:
open the project for analyzing : linkerscript , startup code and elffile,
/home/jaguar/Documents/FreeRtos/nxp/Firmware_project_lpcopen/Blinky_fw_code_work/periph_blinky/Debug
Startup of LPC1768 :
In the Cortex-M3, the initial value for the MSP is put at the beginning of the memory map-0x0000 0000
followed by the vector table, which contains vector address values.
the contents of the vector table are address values, not branch instructions unlike traditional ARM processors.
0x0000 0000 ---> MSP value // ?? how it comes here
0x0000 0004 ---> Reset vector // ?? how it comes here
0x0000 0004 to 0x00000400 ==> other exception vectors
Reset vector = starting address of boot code area.
How these values (MSPvalue ,IRQ Vectors)and corresponding IRQ handlers are loaded in place ??
Target LPC1768 : 512 kB of flash memory, 32 kB on-chip SRAM,
Memory map of LPC1768:
On-chip non-volatile memory : 0x0000 0000 - 0x0007 FFFF (512 KB - flash)
On-chip SRAM : 0x1000 0000 - 0x1000 7FFF (32 KB - SRAM)
Boot-ROM : 0x1FFF 0000 - 0x1FFF 1FFF (8 KB - ROM)
Loading of Executable into Target flash:
when s/w is compiled => It generates object files which contains symbols in several sections
and their offset values.
when these object files are linked :
using linker script specific to memory map of the target device(lpc1768) ,
linker will map each symbol to the specified memory location in target=> generates elf file.
loader will load these sections/symbols/code into flash.
ELF-contents:
LMA(load memory address/Load addr) and VMA(Virtual memory address/Exec addr)
LMA : is the address at which the section will be loaded. (in flash)
VMA: is the address the section will have when the output file is run.
In most cases : LMA = VMA .
example of when they might be different is:
when a data section is loaded into ROM, and then copied into RAM when the program starts up
(this technique is often used to initialize global variables in a ROM based system).
In this case the ROM address would be the LMA, and the RAM address would be the VMA.
both LMA and VMA would be calculated by linker .
After Loading into Flash:
flash contains all the symbols:
i.e
stack base address
Interrupt vectors
details of data and bss sections:
offset(from starting of flash),RAM-load adresses,length of section
ISR code.
global variables initialised to their values ( organised in sections)
constants / ro-data
code section :
Functons=>code manipulating the memory locations(representing variables) in RAM,
code fetching data from flash,ram.
local variables ??
they are managed at run time on the stack and are not of interest to the linker.
local variable int local_var1=200; ==> translated as MVI R0,200;MOV(sp--),R0;
Later when Reset ISR executes: startup code copies global variables (data & bss sections)
from flash to RAM using the addresses of those sections.
Target LPC1768 : 512 kB of flash memory, 32 kB on-chip SRAM,
Memory map of LPC1768:
On-chip non-volatile memory : 0x0000 0000 - 0x0007 FFFF (512 KB - flash)
On-chip SRAM : 0x1000 0000 - 0x1000 7FFF (32 KB - SRAM)
Boot-ROM : 0x1FFF 0000 - 0x1FFF 1FFF (8 KB - ROM)
how stack is setup ?
lpc1768 has full descending stack : stack base should be 0x10007FFF + 1 (Full)=>sp points to filled mem
Linker script:
-------------------
__top_RamLoc32 = 0x10000000 + 0x8000;
_vStackTop = __top_RamLoc32 - 0;
startup_code :
--------------
extern void _vStackTop(void);
=> generate a symbol _vStackTop whose address will be part of irq vectors
__attribute__ ((section(".after_vectors"))) ==> keep this in section called after_vectors
void
ResetISR(void) {
......
.......
}
extern void (* const g_pfnVectors[])(void);
__attribute__ ((section(".isr_vector"))) =====> create a section named isr_vector
void (* const g_pfnVectors[])(void) = {
// Core Level - CM3
&_vStackTop, // The initial stack pointer
ResetISR, // The reset handler
NMI_Handler, // The NMI handler
HardFault_Handler, // The hard fault handler
.........}
Linker script:
MFlash512 (rx) : ORIGIN = 0x0, LENGTH = 0x80000 /* 512K bytes */
SECTIONS
{
/* MAIN TEXT SECTION */
.text : ALIGN(4)
{
FILL(0xff)
__vectors_start__ = ABSOLUTE(.) ; ===> __vectors_start_ = 0x0000 0000 //MFlash512:origin
KEEP(*(.isr_vector)) ====> load isr_vector section here
/* Global Section Table */
. = ALIGN(4) ;
__section_table_start = .; ==> Table describing various sections(.data ,.bss)
...............
...............
__section_table_end = . ;
/* End of Global Section Table */
*(.after_vectors*)
} >MFlash512
based on the Linker script => linker generates the symbol table after merging symbols in various object files.
Symbol table '.symtab' contains 416 entries:
Num: Value Size Type Bind Vis Ndx Name
Num: = The symbol number
Value = The address of the Symbol
Size = The size of the symbol
Type = symbol type: Func = Function, Object, File (source file name), Section = memory section, Notype = untyped absolute symbol or undefined
Bind = GLOBAL binding means the symbol is visible outside the file. LOCAL binding is visible only in the file. WEAK is like global, the symbol can be overridden.
Vis = Symbols can be default, protected, hidden or internal.
Ndx = The section number the symbol is in. ABS means absolute: not adjusted to any section address's relocation
Name = symbol name
jaguar@jaguar-ThinkPad-T540p ~/Documents/FreeRtos/nxp/Firmware_project_lpcopen/Blinky_fw_code_work/periph_blinky/Debug $ arm-none-eabi-readelf -a periph_blinky.axf | grep g_pfnVectors
392: 00000000 204 OBJECT GLOBAL DEFAULT 1 g_pfnVectors
jaguar@jaguar-ThinkPad-T540p ~/Documents/FreeRtos/nxp/Firmware_project_lpcopen/Blinky_fw_code_work/periph_blinky/Debug $ arm-none-eabi-readelf -a periph_blinky.axf | grep _vStackTop
350: 10008000 0 NOTYPE GLOBAL DEFAULT ABS _vStackTop
jaguar@jaguar-ThinkPad-T540p ~/Documents/FreeRtos/nxp/Firmware_project_lpcopen/Blinky_fw_code_work/periph_blinky/Debug $ arm-none-eabi-readelf -a periph_blinky.axf | grep ResetISR
393: 00000171 120 FUNC GLOBAL DEFAULT 1 ResetISR
====> g_pfnVectors : vector table is loaded starting from 0000 0000
====> _vStackTop which is part of vector table has absolute value 10008000 (stack base).
====> ResetISR : reset vector also part of vector table has value 00000171 ( )
====> After the vector table , Global Section Table is loaded.
====> After this IRQ handlers are loaded.
when processor is reset :
processor Fetches Initial Stack pointer value from location 0x00000000 and loads R13=> SP
Fetches Reset vector from 0x0000 0004 and loads pc and jumps to reset-ISR.
Reset Handler:
-----------------------
SectionTable => info about global and bss sections.==> contains below:
start address of data sec on flash (LMA)
start address of data sec on ram (VMA)
lenth of data section
start address of bss sec on ram (VMA)
lenth of data section
data section on flash:
global variables initialized .
static variables initialized.
bss section on flash:
length of bss section ==> we dont need bss variables on flash as they are all initialized to zero.
this saves space on flash.
In reset handler :
data section is copied from flash to ram. => if 10 variables on flash 10 reads from flash, 10 writes to flash
based on bss-length on flash bss section setup in ram
=> if 10 variables in bss : 2 reads(start_addr_bss and len_bss) , 10 writes to flash(zero write).
aslo place saved on flash.
sysinit:
Initialise Vector Table Offset Register (VTOR) to the address where vectors are stored in flash.
this is just for indicating where in the flash vector table starts .
(we can modify VTOR later in code to relocate vector table.)
if __FPU_PRESENT ==> fpuInit
if NO_BOARD_LIB ===> Chip_SystemInit
if BOARD_LIB ======> Board_SystemInit
Board_SystemInit() ==> Board_SetupMuxing/Chip_IOCON_SetPinMuxing : pin muxing (mode and function select) for IO pins
Board_SetupClocking/Chip_SetupXtalClocking : setup clock by selecting and Enabling clock src,
clock dividervalue and PLL.
call main or call redlib's __main==> which calls the main().
SECTIONS
{
/* MAIN TEXT SECTION */
.text : ALIGN(4)
{
FILL(0xff)
__vectors_start__ = ABSOLUTE(.) ; ===> __vectors_start_ = 0x0000 0000 //MFlash512:origin
KEEP(*(.isr_vector)) ====> load isr_vector section here
/* Global Section Table */
. = ALIGN(4) ;
__section_table_start = .; ==> Table describing various sections(.data ,.bss)
__data_section_table = .;
LONG(LOADADDR(.data)); ==> load address of data section in memory (RAM here)
LONG( ADDR(.data)); ==> Address of data section in the current ELF file.
LONG( SIZEOF(.data)); ===> size of data section
LONG(LOADADDR(.data_RAM2)); ===>
LONG( ADDR(.data_RAM2));
LONG( SIZEOF(.data_RAM2));
__data_section_table_end = .;
__bss_section_table = .;
LONG( ADDR(.bss)); ===> Address of bss section in the current ELF file
LONG( SIZEOF(.bss)); ===> size of bss section in the current ELF file
/* bss section in ELF file is just starting address and size.
LONG( ADDR(.bss_RAM2));
LONG( SIZEOF(.bss_RAM2));
__bss_section_table_end = .;
__section_table_end = . ;
/* End of Global Section Table */
*(.after_vectors*)
} >MFlash512
######################################################################################################
context switching in FreeRTOS:
--------------------------------
systick handler:
portNVIC_PENDSVSET
vTaskIncrementTick
xPortPendSVHandler:
--------------------------
#############################################################################################
c99 standard exciting features?
malloc and calloc major difference
int a[14] = { 1,2,3,4,5}; a[6]=?
varible length arrays
what happens when file is included.??
can kernel identify driver with only major number ?
scope of variable in switch case ?
swich case ideal for small no of conditions to check .
If large no of conditions what to use ?
difference between .o file and .ko file
IPC s between kernel space user space??
NETLINK socket using the adress family :AF_NETLINK
note AF_INET => tcp/ip socket
It provides full-duplex communication link
main(){ int *p ; *p = 100; } where p is allocated ?
==> undefined : p may contain junk value
how to remove file created by mknod??
==>
rm -f => no API to call from remove.
Range of minor numbers ? what do when it is exhausted?
major difference between 2.4 and 2.6
==>
1) preemptible option (CONFIG_PREEMPT)
2) unified device model :
2) user spcae program insmod would interpret ELF object(.o) file and do all work of linking it
to running kernel, generating a finished binary
In 2.6 kernel does the linking, insmod will pass the contents of ELF file directly to kernel.
.ko file contatins this additional linking info and differs from .o which was linked & loaded earlier by insmod(2.4 case)
in 2.6 ==> create reguar .o file | run modpost program over .o file => .mod file has additional sections |
compile .mod file and link result with original .o file => .ko file.
L&T face to face:
linked list reverse traversal
tree traversal.
Explain any bug you faced while solving the problem?
what is re-entrant code?
can you open file inside a code section which is executed by two threads.?
CISCO-Intw:
-----------
How to determine Little endian or big-endian ? (not using pointers) : hint=>use symantics of c language.
int is_big_endian(void)
{
union {
uint32_t i;
char c[4];
} e = { 0x01000000 };
return e.c[0];
}
Based on what parameters of RTOS you select RTOS for your application?
priority??
latency??
based on IPC can an RTOS sceduler schedules high-priority task?
how a systemcall enters kernel space.?
#define secs_per_day 86400 (or) #define secs_per_day (24*60*60) ==> which one you prefer, why ??
==> if you substitute this expresion million times in code , does that effects performance?
char *ptr = "hello"; vs char arr[5]="hello";
what is the difference?
ptr points to code-section , arr points to data-section.
what is impact?
we cant modify the string.
how sizeof()works ? why it is an operetor?
i2c-driver :
in i2c driver where do you pass i2c-controller Info?
where do you pass i2c-client Info?
where do you get client-address from?
PATHPARTNER:
fn1()
{
int x= 30;
pthread_create( &x);
pthred_join()
return;
}
thread_fn( int *p)
{
for(;;)
*(++p);
}
write a function for finding number of ones in a integer.
is there any problem if this function is called by several threads.? any race condition?
?
how to find number of characters in File(optimized logic).?
which one is better choice i2c or Spi ? why?
in terms of power consumption, which one is better i2c or spi??
xoRail:
explain volatile with examples?
is volatile applied to variable or pointer ? in the case of register access
is volatile variable can be on stack? or it should be global?
--------------------------------------------------------------------
C-Questions Frequently asked :
DELL--
---------
Linked list - delete node
does static variable be accessed from some other Function?
what is scope of Static variable ? how can you access it in other Fn?
Implement SizeOf-operator.
program to swap even and odd bits of an integer?
int swap_bits(int number)
{
int i=0,p=0,q=1;
for(i=0;i<32;i=i+2)
{
if( ((num & 1<<p)>>p) ^ ((num & 1<<q)>>q) ) //if bits at position p,q are different
{
num = num ^ 1<<p;
num = num ^ 1<<q;
p = p+2;
q = q+2;
}
}
return num;
}