* FAL (Flash Abstraction Layer) initialization. * It will initialize all flash device and all flash partition. * * @return >= 0: partitions total number */
| 28 | * @return >= 0: partitions total number |
| 29 | */ |
| 30 | int fal_init(void) |
| 31 | { |
| 32 | extern int fal_flash_init(void); |
| 33 | extern int fal_partition_init(void); |
| 34 | |
| 35 | int result; |
| 36 | |
| 37 | /* initialize all flash device on FAL flash table */ |
| 38 | result = fal_flash_init(); |
| 39 | |
| 40 | if (result < 0) { |
| 41 | goto __exit; |
| 42 | } |
| 43 | |
| 44 | /* initialize all flash partition on FAL partition table */ |
| 45 | result = fal_partition_init(); |
| 46 | |
| 47 | __exit: |
| 48 | |
| 49 | if ((result > 0) && (!init_ok)) |
| 50 | { |
| 51 | init_ok = 1; |
| 52 | LOG_I("RT-Thread Flash Abstraction Layer initialize success."); |
| 53 | } |
| 54 | else if(result <= 0) |
| 55 | { |
| 56 | init_ok = 0; |
| 57 | LOG_E("RT-Thread Flash Abstraction Layer initialize failed."); |
| 58 | } |
| 59 | |
| 60 | return result; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Check if the FAL is initialized successfully |